Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 09:16 01 Aug 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : CMM2: Keyboard Codes - Arrows and Shift

Author Message
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1132
Posted: 01:33am 18 Dec 2020
Copy link to clipboard 
Print this post

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: Australia
Posts: 6283
Posted: 02:56am 18 Dec 2020
Copy link to clipboard 
Print this post

  [ said  QUOTE=vegipete
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)
.

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: Australia
Posts: 6283
Posted: 07:09am 18 Dec 2020
Copy link to clipboard 
Print this post

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 Kingdom
Posts: 10310
Posted: 08:37am 18 Dec 2020
Copy link to clipboard 
Print this post

  Quote  As far as I can see, there are 4 undocumented


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 Republic
Posts: 533
Posted: 09:03am 18 Dec 2020
Copy link to clipboard 
Print this post

And 159+160 are my favarites  
Jiri
Napoleon Commander and SimplEd for CMM2 (GitHub),  CMM2.fun
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1132
Posted: 10:07pm 18 Dec 2020
Copy link to clipboard 
Print this post

  matherp said  
  Quote  As far as I can see, there are 4 undocumented


No, only two undocumented - check appendix F. I'll ask Geoff to update with the missing 2

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.
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025