LinuxCommandLibrary

kbd_mode

Change keyboard mode (raw, virtual console)

SYNOPSIS

kbd_mode [-a|-k|-r] [-u]

PARAMETERS

-a
    Set ANSI (application) mode.

-k
    Set VC (virtual console) or normal mode (the default).

-r
    Set RAW mode.

-u
    Unload translation table. If the keyboard mode is raw, this is needed to restore normal keyboard functioning. If the keyboard mode is vc, then an error is thrown.

DESCRIPTION

The kbd_mode command allows you to query and set the keyboard mode of the Linux console. It's primarily used to switch between raw, virtual console (VC), and American National Standard Institute (ANSI) modes. The default mode is VC, where the kernel interprets key presses. Raw mode sends keycodes directly to a process, bypassing the kernel's keyboard handling. ANSI mode translates specific key sequences (e.g., function keys) into ANSI escape sequences, commonly used by terminal emulators.

Caution: Setting an incorrect mode can make the keyboard unusable. Raw mode is useful for specialized applications that require direct access to keyboard input. VC mode is the standard mode for interacting with the Linux console. ANSI mode can be helpful for applications expecting terminal-style input. Use it with caution, as it changes default keyboard behavior.

CAVEATS

Setting raw mode without understanding its implications can render the keyboard unusable until the mode is changed back (potentially requiring a reboot if you cannot switch ttys with ALT-F#). Ensure a way to revert the changes. Using `-u` after setting to raw mode is typically how to restore keyboard functionality. The command requires root privileges to function.

UNDERSTANDING MODES

Raw Mode: Bypasses kernel key handling, providing direct keycodes.
VC Mode: Standard console mode, where the kernel interprets keypresses.
ANSI Mode: Translates key sequences into ANSI escape codes.

SEE ALSO

Copied to clipboard