Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

In the magic sysrq key combinations, there is the combination alt+sysrq+r which, according to wikipedia, does the following:

Switch the keyboard from raw mode, the mode used by programs such as X11 and svgalib, to XLATE mode

What is raw mode? and what is XLATE mode?

Can I switch back to raw mode once I have switched to XLATE mode?

How can I tell which mode my keyboard is in?

share|improve this question
add comment

2 Answers 2

up vote 8 down vote accepted

When you press a key on your keyboard, it sends a numeric code to the computer, called a scan code. The scan code tells the computer which key was pressed; for example, on a typical US keyboard, the A key sends the scan code 30 when you press it (and 158 when you release it). The keyboard driver reports these codes directly to applications when the keyboard is in raw mode (“raw” means unprocessed, straight off-the-keyboard). A few programs use raw mode and do their own keyboard processing; the X server is the most prominent one.

Most programs expect that when you press the A key, the program reads the character a (ASCII 97), and that when you press Shift+A the program reads A (ASCII 65), and when you press Ctrl+A the program reads the Ctrl+A character (ASCII 1). Keys that don't have associated characters send escape sequences, e.g. \e[A for Left, where \e is the ESC character (ASCII 27). The keyboard driver performs this translation when the keyboard is in ASCII mode, also called XLATE mode (short for “translate”). XLATE mode lets applications do character input, at the cost of not having access to such nuances as “Left Shift key pressed” or Ctrl+Shift+A as distinct from Ctrl+A.

The kbd_mode lets you switch between modes, and shows the current mode if you invoke it without any argument.

The magic SysRq key combinations are meant to recover from various nasty situations. One of the key combinations is Alt+SysRq+K to kill all programs on the current virtual console; if that program put the keyboard in raw mode, then you won't be able to type at the login prompt (which will often appear, depending on your system configuration). Pressing Alt+SysRq+R restores the usual (outside X) ASCII mode where you can type characters.

share|improve this answer
add comment

You can define which type of code your keyboard sends. This is done via the keyboard mode. You can change the mode of a keyboard with kbd_mode.

These are the options from the manpage:

   -s: scancode mode (RAW),
   -k: keycode mode (MEDIUMRAW),
   -a: ASCII mode (XLATE),
   -u: UTF-8 mode (UNICODE).

Its much easier for a developer to catch key events like left shift key pressed, if he can simply get the scancodes of the pressed keys.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.