Keypad Entry - Printable Version +- QB64 Phoenix Edition (https://qb64phoenix.com/forum) +-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1) +--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3) +---- Forum: Help Me! (https://qb64phoenix.com/forum/forumdisplay.php?fid=10) +---- Thread: Keypad Entry (/showthread.php?tid=1373) Pages:
1
2
|
Keypad Entry - eoredson - 01-07-2023 I am working on a project that requires keypad entry. The problem is that QB64 does not trap them!? Here is my code: Code: (Select All) Rem Keypad-5 = 76 RE: Keypad Entry - mnrvovrfc - 01-07-2023 Use _KEYHIT or _KEYDOWN instead. https://qb64phoenix.com/qb64wiki/index.php/KEYHIT https://qb64phoenix.com/qb64wiki/index.php/KEYDOWN RE: Keypad Entry - eoredson - 01-08-2023 (01-07-2023, 06:22 AM)mnrvovrfc Wrote: Use _KEYHIT or _KEYDOWN instead. I tried this code with _keyhit and still does not return keypad-5: Code: (Select All) Rem Keypad-5 = 76 RE: Keypad Entry - bplus - 01-09-2023 SMcNeill probably knows your pain best as he has posted special key handling code a number of times. If he doesn't pipe in, try some searches with him posting. RE: Keypad Entry - SMcNeill - 01-09-2023 Aye. It's an issue which faces not just QB64, but anything built upon glut as its core. We're working on it, but until then, you might want to make use of my keyboard library or use windows native functions for your program. RE: Keypad Entry - JRace - 01-09-2023 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 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 ) RE: Keypad Entry - eoredson - 01-09-2023 I am using numlock off and pressing keypad-5 and get the same results.. Should I assume a return value of -12 indicates keypad-5? Erik. RE: Keypad Entry - mnrvovrfc - 01-09-2023 This might be the main reason why some programs bid the user to make sure "NUMLOCK" is off. Then that "5" number pad key isn't even used. A "portable" way is just to allow the user to choose his/her keypresses, or to kindly ask him/her to make sure "NUMLOCK" is on or off, and then work on things from there. Also warn there will be no guarantees about functionality if the user doesn't follow instructions. Remember also that your program could be used by somebody on a budget laptop, which is too small, or was designed in such a way to leave no room for a numeric keypad. I have two HP computers which are this way. I have another computer, ASUS which has a trick to use the touchpad as numeric keypad. RE: Keypad Entry - JRace - 01-09-2023 (01-09-2023, 03:48 AM)eoredson Wrote: I am using numlock off and pressing keypad-5 and get the same results.. It might be worth a try. My quick test does not show any other key returning -12. I'm sorry, but I know very little about the internals of QB64PE and don't know where those key values are being generated. RE: Keypad Entry - TerryRitchie - 01-09-2023 I happened to be awake the other night when this was first posted and played around with some code to come up with a solution. I was surprised that I could not get this to work properly either in the 45 minutes I tinkered with it. I see from the replies that it wasn't just me. |