(12-20-2023, 07:14 PM)SpriggsySpriggs Wrote:Just within QB64 - I just tested it in Notepad - with NumLock on, the numeric keypad outputs numbers, with NumLock off, it behaves like cursor keys, etc.(12-20-2023, 06:30 PM)madscijr Wrote: Also, on my PC, the numeric keypad keys work whether num lock is on or off...Is that globally or is that just within QB64? I've never seen where numkeys work when numlock is disabled. They usually behave as arrow keys. Do you have some program/plugin/service that is running that might be intercepting the numlock key?
It might be worth noting that I use _BUTTON to detect keypresses, which might have something to do with it.
Apparently _BUTTON detects the numeric keypad keys completely seperately from the number row and cursor keys, so it doesn't matter whether NumLock is on or off.
Below is a little test program that just verifies the behavior with NumLock - run it, turn numlock off,
then try pressing 2, 4, 6, 8 on the number row, 2, 4, 6, 8 on the numeric keypad, and the regular cursor keys.
Then turn numlock on, and try those keys again. No difference!
Code: (Select All)
' TEST PROGRAM TO VERIFY _BUTTON DETECTS NUMERIC KEYPAD KEYS AS CURSOR KEYS
' AND NOT NUMBERS WHETHER NUMLOCK IS ON OR OFF
Const FALSE = 0
Const TRUE = Not FALSE
' ----------------------------------------------------------------------------------------------------------------------------------------------------------------
' BEGIN KEYBOARD CODE CONSTANTS FOR _BUTTON #KEYBOARD
' ----------------------------------------------------------------------------------------------------------------------------------------------------------------
' +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
' FUNCTION KEYS ROW
Const c_bKey_Esc% = 2
Const c_bKey_F1% = 60
Const c_bKey_F2% = 61
Const c_bKey_F3% = 62
Const c_bKey_F4% = 63
Const c_bKey_F5% = 64
Const c_bKey_F6% = 65
Const c_bKey_F7% = 66
Const c_bKey_F8% = 67
Const c_bKey_F9% = 68
'UNKNOWN: Const c_bKey_F10% = '(_BUTTON code unknown)
Const c_bKey_F11% = 88
Const c_bKey_F12% = 89
' +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
' NUMBERIC ROW
Const c_bKey_Tilde% = 42
Const c_bKey_1% = 3
Const c_bKey_2% = 4
Const c_bKey_3% = 5
Const c_bKey_4% = 6
Const c_bKey_5% = 7
Const c_bKey_6% = 8
Const c_bKey_7% = 9
Const c_bKey_8% = 10
Const c_bKey_9% = 11
Const c_bKey_0% = 12
Const c_bKey_Minus% = 13
Const c_bKey_Equal% = 14
Const c_bKey_BkSp% = 15
' +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
' QWER ROW
Const c_bKey_Tab% = 16
Const c_bKey_Q% = 17
Const c_bKey_W% = 18
Const c_bKey_E% = 19
Const c_bKey_R% = 20
Const c_bKey_T% = 21
Const c_bKey_Y% = 22
Const c_bKey_U% = 23
Const c_bKey_I% = 24
Const c_bKey_O% = 25
Const c_bKey_P% = 26
Const c_bKey_BracketLeft% = 27
Const c_bKey_BracketRight% = 28
Const c_bKey_Backslash% = 44
' +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
' ASDF ROW
Const c_bKey_CapsLock% = 59
Const c_bKey_A% = 31
Const c_bKey_S% = 32
Const c_bKey_D% = 33
Const c_bKey_F% = 34
Const c_bKey_G% = 35
Const c_bKey_H% = 36
Const c_bKey_J% = 37
Const c_bKey_K% = 38
Const c_bKey_L% = 39
Const c_bKey_Semicolon% = 40
Const c_bKey_Apostrophe% = 41
Const c_bKey_Enter% = 29
' +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
' ZXCV ROW
Const c_bKey_ShiftLeft% = 43
Const c_bKey_Z% = 45
Const c_bKey_X% = 46
Const c_bKey_C% = 47
Const c_bKey_V% = 48
Const c_bKey_B% = 49
Const c_bKey_N% = 50
Const c_bKey_M% = 51
Const c_bKey_Comma% = 52
Const c_bKey_Period% = 53
Const c_bKey_Slash% = 54
Const c_bKey_ShiftRight% = 55
' +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
' SPACEBAR ROW
Const c_bKey_LeftCtrl% = 30
Const c_bKey_WinLeft% = 348
'UNKNOWN: Const c_bKey_AltLeft% = '(_BUTTON code unknown)
Const c_bKey_Spacebar% = 58
'UNKNOWN: Const c_bKey_AltRight% = '(_BUTTON code unknown)
Const c_bKey_WinRight% = 349
Const c_bKey_Menu% = 350
Const c_bKey_RightCtrl% = 286
' +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
' NAVIGATION KEYS
Const c_bKey_Ins% = 339
Const c_bKey_Home% = 328
Const c_bKey_PgUp% = 330
Const c_bKey_Del% = 340
Const c_bKey_End% = 336
Const c_bKey_PgDn% = 338
' +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
' CURSOR KEYS
Const c_bKey_Up% = 329
Const c_bKey_Left% = 332
Const c_bKey_Down% = 337
Const c_bKey_Right% = 334
' +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
' PRINT SCREEN, SCROLL LOCK, PAUSE/BREAK SECTION
'UNKNOWN: Const c_bKey_PrintScreen% = '(_BUTTON code unknown)
Const c_bKey_ScrollLock% = 71
'UNKNOWN: Const c_bKey_PauseBreak% = '(_BUTTON code unknown)
' +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
' NUMERIC KEYPAD
Const c_bKey_NumLock% = 326
Const c_bKey_KeypadSlash% = 310
Const c_bKey_KeypadMultiply% = 56
Const c_bKey_KeypadMinus% = 75
Const c_bKey_Keypad7Home% = 72
Const c_bKey_Keypad8Up% = 73
Const c_bKey_Keypad9PgUp% = 74
Const c_bKey_KeypadPlus% = 79
Const c_bKey_Keypad4Left% = 76
Const c_bKey_Keypad5% = 77
Const c_bKey_Keypad6Right% = 78
Const c_bKey_Keypad1End% = 80
Const c_bKey_Keypad2Down% = 81
Const c_bKey_Keypad3PgDn% = 82
Const c_bKey_KeypadEnter% = 285
Const c_bKey_Keypad0Ins% = 83
Const c_bKey_KeypadPeriodDel% = 84
' ----------------------------------------------------------------------------------------------------------------------------------------------------------------
' END KEYBOARD CODE CONSTANTS FOR _BUTTON @KEYBOARD
' ----------------------------------------------------------------------------------------------------------------------------------------------------------------
' BASIC PROGRAM METADATA
Dim Shared m_ProgramPath$: m_ProgramPath$ = Left$(Command$(0), _InStrRev(Command$(0), "\"))
Dim Shared m_ProgramName$: m_ProgramName$ = Mid$(Command$(0), _InStrRev(Command$(0), "\") + 1)
' START THE MAIN ROUTINE
main
' FINISH
System ' return control to the operating system
End
' /////////////////////////////////////////////////////////////////////////////
Sub main
Do
While _DeviceInput(1): Wend ' clear and update the keyboard buffer
Cls
Color 0, 3: Print "CURSOR KEYS :";: Color 7, 0: Print " ";
If _Button(c_bKey_Left) Then Color 0, 7 Else Color 7, 0
Print "LEFT";
Color 7, 0: Print " ";
If _Button(c_bKey_Right) Then Color 0, 7 Else Color 7, 0
Print "RIGHT";
Color 7, 0: Print " ";
If _Button(c_bKey_Up) Then Color 0, 7 Else Color 7, 0
Print "UP";
Color 7, 0: Print " ";
If _Button(c_bKey_Down) Then Color 0, 7 Else Color 7, 0
Print "DOWN";
Color 7, 0: Print: Print
Color 0, 3: Print "NUMERIC KEYPAD:";: Color 7, 0: Print " ";
If _Button(c_bKey_Keypad4Left) Then Color 0, 7 Else Color 7, 0
Print "4/LEFT";
Color 7, 0: Print " ";
If _Button(c_bKey_Keypad6Right) Then Color 0, 7 Else Color 7, 0
Print "6/RIGHT";
Color 7, 0: Print " ";
If _Button(c_bKey_Keypad8Up) Then Color 0, 7 Else Color 7, 0
Print "8/UP";
Color 7, 0: Print " ";
If _Button(c_bKey_Keypad2Down) Then Color 0, 7 Else Color 7, 0
Print "2/DOWN";
Color 7, 0: Print: Print
Color 0, 3: Print "NUMBER KEYS :";: Color 7, 0: Print " ";
If _Button(c_bKey_4) Then Color 0, 7 Else Color 7, 0
Print "4";
Color 7, 0: Print " ";
If _Button(c_bKey_6) Then Color 0, 7 Else Color 7, 0
Print "6";
Color 7, 0: Print " ";
If _Button(c_bKey_8) Then Color 0, 7 Else Color 7, 0
Print "8";
Color 7, 0: Print " ";
If _Button(c_bKey_2) Then Color 0, 7 Else Color 7, 0
Print "2";
Color 7, 0: Print: Print
Color 0, 3: Print "LOCK KEYS :";: Color 7, 0: Print " ";
If _NumLock Then
Color 0, 7
Print "_NumLock=TRUE";
Else
Color 7, 0
Print "_NumLock=FALSE";
End If
Color 7, 0
Print: Print
Print "PRESS <ESC> TO EXIT"
If _Button(c_bKey_Esc) Then Exit Do
_Limit 100 ' keep loop at 100 frames per second
Loop Until _KeyDown(27) ' leave loop when ESC key pressed
' CLEAR KEYBOARD BUFFER
_KeyClear: '_DELAY 1
End Sub ' main