![]() |
Forum Index : Microcontroller and PC projects : CMM2: Keyboard Codes - Arrows and Shift
Author | Message | ||||
vegipete![]() Guru ![]() Joined: 29/01/2013 Location: CanadaPosts: 1132 |
I've been experimenting a bit with reading the keyboard and have puzzled myself slightly. The following will display the ascii code of any key pressed, along with the state of the modifiers: (left and right shift/ctrl/alt/gui) do do : k = asc(inkey$) : loop until k <> 0 print @(400,100) k, bin$(keydown(7),8) " " loop The arrow keys give 128,129,130,131 as expected. However, holding a SHIFT key and pressing arrows is giving unexpected results: L_SHIFT+LEFT 130 00001000 fine L_SHIFT+UP 128 00001000 fine L_SHIFT+DOWN 161 00001000 huh? Why not 129? L_SHIFT+RIGHT 163 00001000 huh? Why not 131? Are the codes for shifted down and right just weird for my keyboard or is something else going on? Shift-numberpad-arrows gives the expected results, as do other modifiers. It's only shift-down and shift-right that are weird. Do others see the same? (Using MMBasic Version 5.06.00RC4) . Edited 2020-12-18 11:34 by vegipete Visit Vegipete's *Mite Library for cool programs. |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6283 |
I get the same results here If you try playing at a command prompt in Windows, you will find that shift-right and shift-down are used for selection extend so I don't think it is purely a MMBasic thing. Jim VK7JH MMedit |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6283 |
You can add shift-delete = 160 and shift-tab = 159 to the list As far as I can see, there are 4 undocumented shift-tab 159 shift-delete 160 shift-down 161 shift-right 163 Numeric keypads are always going to be strange so I have left that alone. Jim Edited 2020-12-18 17:18 by TassyJim VK7JH MMedit |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10310 |
No, only two undocumented - check appendix F. I'll ask Geoff to update with the missing 2 |
||||
jirsoft![]() Guru ![]() Joined: 18/09/2020 Location: Czech RepublicPosts: 533 |
And 159+160 are my favarites ![]() Jiri Napoleon Commander and SimplEd for CMM2 (GitHub), Â CMM2.fun |
||||
vegipete![]() Guru ![]() Joined: 29/01/2013 Location: CanadaPosts: 1132 |
So all (USB) keyboards are supposed to work this way? Jolly good, I will write my program according to this behaviour. Visit Vegipete's *Mite Library for cool programs. |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |