What are the scan codes for keyboard arrows? (right,left,down,up)
Asked Answered
S

3

5

I need scan codes for arrows (right,left,down,up). I am making software in Assembler and I need to know the hex values for the scan codes of the keyboard arrows.

Savate answered 20/4, 2014 at 22:59 Comment(6)
Do you need scan codes for the keyboard arrow keys, or ASCII codes for arrow characters? Those are different numbers. The latter might be codepage dependent.Sharilyn
codes for the keyboard arrow keysSavate
No such thing as just "code". Do you want to detect arrow key presses or display arrows on screen?Sharilyn
to detect arrow key pressesSavate
Scan codes, then. See my answer.Sharilyn
@TechNomad This is the first time I hear about ascii codes for arrows. Could you show me how these characters look like? The author of the post clearly meant scan codes as was clarified in the comments back in 2014. I edited it because I thought the question should be reopened.Recognizance
S
13

Those are the character codes for arrow characters in the lower portion of the ASCII codepage:

  • Up: 0x18
  • Down: 0x19
  • Right: 0x1A
  • Left: 0x1B

There are also arrow characters in Unicode.

And the scan codes for the arrow keys are:

  • Up: 0x48
  • Left: 0x4B
  • Right: 0x4D
  • Down: 0x50

Notice the different order.

The scan codes are returned, for example, from the BIOS interrupt 16h. In general, scan codes don't correspond to ASCII characters, because some keys legitimately don't represent a character - like Shift, or Caps Lock, or the arrow keys. Those don't produce a character in the input stream, but they do have scan codes, and programs are capable of retrieving those.

Even the alphanumeric keys that do correspond to characters may represent different characters at different time, depending on Shift and on the chosen keyboard layout.

Whatever Linux thinks, neither the keyboard nor the screen are byte streams.

Sharilyn answered 20/4, 2014 at 23:12 Comment(0)
A
2

Great can obtain scan codes in linux with:

sudo showkey -s
  • Up: 0x48 (pressing) 0xc8 (release)
  • Down: 0x50 (press) 0xd0 (release)
  • Left: 0x4b (press) 0xcb (release)
  • Right: 0x4d (press) 0xcd (release)
Arlindaarline answered 30/10, 2016 at 14:37 Comment(0)
M
-2

Here are the codes you're looking for...

  • Left: AC
  • Up: AD
  • Right: AE
  • Down: AF
Mcafee answered 20/4, 2014 at 23:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.