The Wayback Machine - https://web.archive.org/web/20250115012655/https://www.geeksforgeeks.org/getkeycodes-command-in-linux-with-examples/
Open In App

getkeycodes command in Linux with examples

Last Updated : 23 Sep, 2024
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

‘getkeycodes’ command in Linux is used to print the kernel scancode-to-keycode mapping table. This command has no option. setkeycodes command can be used to change the mappings. By using the ‘getkeycodes‘ command, you can view these mappings and understand how your keyboard inputs are translated by the Linux kernel.

Here, we will look into the ‘getkeycodes’ command, its usage, and how it relates to the ‘setkeycodes’ command for modifying scancode mappings

Syntax

getkeycodes

Once executed, this command prints the scancode-to-keycode mapping table to the terminal. The scancodes are represented in hexadecimal format (e.g., 0x01, 0x02, etc.), while the corresponding keycodes are in decimal format.

getkeycodes Command Example

Let’s look at an example of running the getkeycodes command in a Linux terminal:

In the output:

  • The values starting with 0x are scancodes (in hexadecimal format).
  • The numbers following each scancode are keycodes (in decimal format) that correspond to each scancode.

For example:

  • Scancode “0x54” is mapped to keycode 99.
  • Scancode “0x01” to “0x53” have direct keycode mappings (shown in the table).

Conclusion

The ‘getkeycodes’ command is an essential tool for viewing the scancode-to-keycode mapping in Linux, helping users understand how the system interprets keyboard inputs. This command is invaluable for controlling how your Linux system interacts with hardware input.

getkeycodes command in Linux – FAQs

What is the difference between scancode and keycode?

  • Scancode: A hardware-generated code that corresponds to a physical keypress.
  • Keycode: A software-interpreted code that tells the system what action or character to produce based on the scancode.

Can I remap keys using getkeycodes?

No, getkeycodes only displays the current scancode-to-keycode mapping. To remap keys, you must use the setkeycodes command.

How do I check if a key is properly mapped?

You can use getkeycodes to view the scancode-to-keycode mapping and verify if a specific key is mapped correctly. If the key is not functioning as expected, you can remap it using setkeycodes.

Is getkeycodes available on all Linux distributions?

Yes, the getkeycodes command is typically available in all major Linux distributions as part of the


Master DevOps and also get 90% Course fee refund on completing 90% course in 90 days! Take the Three 90 Challenge today.

The most sought-after Three 90 challenge has started and this is your chance to upskill and get 90% refund. What more motivation do you need? Start the challenge right away!


Article Tags :

Similar Reads

three90RightbarBannerImg