{
    "mode": "man",
    "parameter": "showkey",
    "section": "1",
    "url": "https://www.chedong.com/phpMan.php/man/showkey/1/json",
    "generated": "2026-06-15T13:23:47Z",
    "synopsis": "showkey [-h|--help] [-a|--ascii] [-s|--scancodes] [-k|--keycodes] [-V|--version]",
    "sections": {
        "NAME": {
            "content": "showkey - examine the codes sent by the keyboard\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "showkey [-h|--help] [-a|--ascii] [-s|--scancodes] [-k|--keycodes] [-V|--version]\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "showkey prints to standard output either the scan codes or the keycode or the `ascii' code of\neach key pressed.  In the first two modes the program runs  until  10  seconds  have  elapsed\nsince  the  last  key  press  or  release event, or until it receives a suitable signal, like\nSIGTERM, from another process.  In `ascii' mode the program terminates when  the  user  types\n^D.\n\nWhen  in scancode dump mode, showkey prints in hexadecimal format each byte received from the\nkeyboard to the standard output. A new line is printed when an interval of about 0.1  seconds\noccurs  between the bytes received, or when the internal receive buffer fills up. This can be\nused to determine roughly, what byte sequences the keyboard sends at  once  on  a  given  key\npress.  The scan code dumping mode is primarily intended for debugging the keyboard driver or\nother low level interfaces. As such it shouldn't be of much interest to the regular end-user.\nHowever,  some modern keyboards have keys or buttons that produce scancodes to which the ker‐\nnel does not associate a keycode, and, after finding out what these are, the user can  assign\nkeycodes with setkeycodes(8).\n\nWhen in the default keycode dump mode, showkey prints to the standard output the keycode num‐\nber or each key pressed or released. The kind of the event, press or  release,  is  also  re‐\nported.   Keycodes  are numbers assigned by the kernel to each individual physical key. Every\nkey has always only one associated keycode number, whether the keyboard sends single or  mul‐\ntiple  scan codes when pressing it. Using showkey in this mode, you can find out what numbers\nto use in your personalized keymap files.\n\nWhen in `ascii' dump mode, showkey prints to the standard  output  the  decimal,  octal,  and\nhexadecimal value(s) of the key pressed, according to he present keymap.\n",
            "subsections": []
        },
        "OPTIONS": {
            "content": "-h --help\nshowkey prints to the standard error output its version number, a compile option and a\nshort usage message, then exits.\n\n-s --scancodes\nStarts showkey in scan code dump mode.\n\n-k --keycodes\nStarts showkey in keycode dump mode. This is the default, when no command line options\nare present.\n\n-a --ascii\nStarts showkey in `ascii' dump mode.\n\n-V --version\nshowkey prints version number and exits.\n",
            "subsections": [
                {
                    "name": "2.6 KERNELS",
                    "content": "In 2.6 kernels key codes lie in the range 1-255, instead of 1-127.  Key codes larger than 127\nare returned as three bytes of which the low order 7 bits are: zero, bits 13-7, and bits  6-0\nof the key code.  The high order bits are: 0/1 for make/break, 1, 1.\n\nIn  2.6  kernels  raw  mode,  or scancode mode, is not very raw at all.  Scan codes are first\ntranslated to key codes, and when scancodes are desired, the key codes are  translated  back.\nVarious  transformations are involved, and there is no guarantee at all that the final result\ncorresponds to what the keyboard hardware did send. So, if you want to know  the  scan  codes\nsent  by  various  keys it is better to boot a 2.4 kernel. Since 2.6.9 there also is the boot\noption atkbd.softraw=0 that tells the 2.6 kernel to return the actual scan codes.\n"
                }
            ]
        },
        "SEE ALSO": {
            "content": "loadkeys(1), dumpkeys(1), keymaps(5), setkeycodes(8)\n\n\n\nkbd                                          1 Feb 1998                                   SHOWKEY(1)",
            "subsections": []
        }
    },
    "summary": "showkey - examine the codes sent by the keyboard",
    "flags": [],
    "examples": [],
    "see_also": [
        {
            "name": "loadkeys",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/loadkeys/1/json"
        },
        {
            "name": "dumpkeys",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/dumpkeys/1/json"
        },
        {
            "name": "keymaps",
            "section": "5",
            "url": "https://www.chedong.com/phpMan.php/man/keymaps/5/json"
        },
        {
            "name": "setkeycodes",
            "section": "8",
            "url": "https://www.chedong.com/phpMan.php/man/setkeycodes/8/json"
        }
    ],
    "tldr": {
        "source": "official",
        "description": "Display the keycode of pressed keys on the keyboard, helpful for debugging keyboard-related issues and key remapping.",
        "examples": [
            {
                "description": "View keycodes in decimal",
                "command": "sudo showkey"
            },
            {
                "description": "Display scancodes in hexadecimal",
                "command": "sudo showkey {{-s|--scancodes}}"
            },
            {
                "description": "Display keycodes in decimal (default)",
                "command": "sudo showkey {{-k|--keycodes}}"
            },
            {
                "description": "Display keycodes in ASCII, decimal, and hexadecimal",
                "command": "sudo showkey {{-a|--ascii}}"
            },
            {
                "description": "Exit the program",
                "command": "<Ctrl d>"
            }
        ]
    }
}