Home

scancodes

Scancodes are the numeric codes produced by a computer keyboard to report key presses and releases to the host computer. When a key is pressed, the keyboard transmits a make code; when the key is released, it transmits a break code. These codes are the lowest-level representation of keyboard input and are largely independent of character encoding.

In PS/2 and early PC keyboard architectures, several scancode sets exist, notably Set 1, Set 2, and

Programming interfaces or firmware translate scancodes into higher-level events, such as ASCII characters or OS-specific key

With USB keyboards, devices now use the HID (Human Interface Device) protocol and report usage IDs rather

Set
3.
Set
1
is
common
on
IBM
PC-compatible
systems.
Some
keys
are
sent
with
an
extended
prefix,
typically
0xE0,
to
indicate
features
like
the
right-hand
Control
key
or
Arrow
keys;
Pause/Break
uses
a
special
sequence
and
is
not
a
simple
pair
of
make/break
codes.
events.
The
exact
mapping
from
scancodes
to
characters
depends
on
the
keyboard
layout
and
the
operating
system.
In
practice,
a
keyboard
driver
may
expose
a
unified
map
from
scancodes
to
virtual
key
codes,
and
then
to
characters,
taking
layout
into
account.
than
hardware
scancodes;
computer
systems
typically
translate
HID
usages
into
scancodes
or
key
events
via
a
driver.
As
a
result,
the
term
“scancode”
is
sometimes
used
to
refer
to
the
host-facing
code
in
OS-specific
input
stacks
rather
than
the
physical
hardware
signal.