Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 742
Marko Stojkovic Avatar asked Apr 20 '14 22:04

Marko Stojkovic


People also ask

What are keyboard scan codes?

A scancode (or scan code) is the data that most computer keyboards send to a computer to report which keys have been pressed. A number, or sequence of numbers, is assigned to each key on the keyboard.

What are the arrow keys called in code?

The arrows are known as cursor control keys (the cursor is the flashing bar on the computer screen that shows your current position). Many keyboards also have a separate pad for these keys (look for a set of arrow keys).

What are the up down left right keys called?

The arrow keys are used in many applications to do different things such as: Moving text cursor to the right, left, previous line and next line.


2 Answers

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

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

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.

like image 133
Seva Alekseyev Avatar answered Sep 20 '22 22:09

Seva Alekseyev


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)
like image 34
Thedemon007 Avatar answered Sep 19 '22 22:09

Thedemon007