Open In App

showkey command in Linux with Examples

Last Updated : 27 Sep, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

showkey command in Linux is used to examine the codes sent by the keyboard. showkey prints to standard output either the scan codes or the key code or the ‘ASCII’ code of each key pressed. The program runs in the first two modes until 10 seconds have elapsed since the last key press or release event, or until it receives a suitable signal, like SIGTERM, from another process. In `ascii’ mode the program terminates when the user types ^D (Ctrl+D).

Syntax

showkey [-h|--help] [-a|--ascii] [-s|--scancodes] [-k|--keycodes]

Basic Example

To start using the showkey command and examine the codes sent by your keyboard, run the following:

sudo showkey

Basic Example

This will display the key codes for each key pressed on the keyboard.

Key Options with the showkey command

1. showkey -h:

This option prints to the standard error output its version number, a compile option and a short usage message, then exits.

sudo showkey -h

showkey -h

2. showkey -s:

To start showkey in scan code dump mode, use the -s option. This will display the raw scan codes sent by the keyboard:

sudo showkey -s

showkey -s

3. showkey -k:

This option starts showkey in keycode dump mode. This is the default when no command line options are present.

sudo showkey -k

showkey -k

4. showkey -a:

This option will start showkey in ‘ascii’ dump mode.

sudo showkey -a

showkey -a

Conclusion

The showkey command in Linux is a powerful tool for examining and diagnosing keyboard inputs. Whether you’re trying to capture scan codes, key codes, or ASCII values, this command provides valuable information for debugging and troubleshooting. It’s particularly useful for keyboard diagnostics, key remapping, and developers working on input devices.


Next Article

Similar Reads