Quote:I am working on a project that requires keypad entry.
Are you looking for ASCII input (with NumLock on), or navigation key input (with NumLock off)?
Either version of your test program should return proper ASCII values for the digit keys if NumLock is on.
I modified your second tester to print only the raw data that it sees, and also to print that data to a text file "k2out.txt":
Code: (Select All)
Rem Keypad-5 = 76
Rem Shift-Keypad-5 = 53
Rem Ctrl-Keypad-5 = 143
Open "o", 1, "k2out.txt"
Do
X = _KeyHit
If X Then
Print "Keypress="; X; "("; (X And &HFF00) / 256; ")"
Print #1, "Keypress="; X; "("; (X And &HFF00) / 256; ")"
If X = 27 Then End
End If
Loop
Close
End
and....
Each key sends a "make" code when pressed (or held down), and a "break" code when released, except for numpad-5....
With NumLock on, each key (including numpad-5) sends the appropriate ASCII value when the key is pressed or held down. It sends a sign-flipped ASCII value when the key is released.
With NumLock off, each key sends a "make" code when the key is pressed (these will also repeat if held down), and also a "break" code when released, EXCEPT for numpad-5, which has no alternate non-numeric function. Numpad-5 sends nothing when pressed or held, and only a single, non-repeating "break" code when the key is released.
Below are tables of the keycodes my modified tester sees.
The first table is the result of pressing & releasing the numpad keys 4, 5, & 6 with NumLock on.
The second table is the result of pressing & releasing the numpad keys 4, 5, & 6 with NumLock off.
With NumLock on:
4: Keypress= 52 ( 0 )
Keypress=-52 (-1 )
5: Keypress= 53 ( 0 )
Keypress=-53 (-1 )
6: Keypress= 54 ( 0 )
Keypress=-54 (-1 )
ESC: Keypress= 27 ( 0 )
==============================
==============================
==============================
With NumLock off:
4: Keypress= 19200 ( 75 )
Keypress=-19200 (-75 )
5: (NOTE: no "make" code is sent when NumLock is off)
Keypress=-12 (-1 )
6: Keypress= 19712 ( 77 )
Keypress=-19712 (-77 )
ESC: Keypress= 27 ( 0 )