showkey | Examine Keyboard Codes

I was having a peculiar issue with my computer where the “]” key kept getting pressed over and over again. It was very aggravating and I wasn’t sure where the problem was coming from. Neither my external keyboard nor the laptop keyboard would respond when I would press the “]” key and I was confused. As part of my investigation, I became aware of a command line tool called “showkey” that helped me figure out what was going on with my computer. I largely lifted this information from the Geeks for Geeks website but I wanted to comment on the details my own way and also describe how I used it to help me.

Installation

I don’t know showkey is not a standalone application for the command line but a part of another package called kbd on openSUSE. It may be the same on other distributions, I haven’t investigated this so I can’t say for sure. Likely, this is not something you will have to install.

Use

The use of showkey is rather simple. You have four options and one of them is to show help.

Simple Use

In the terminal just simply type:

sudo showkey

This will show whatever key you are pressing by it’s keycode:

You may not need anything more than this basic usage as this is all I needed to figure out my problem but I took it as an opportunity to learn more about it.

Help option

This is the help or information about showkey.

showkey -h

This displays the basic help information about showkey.

Ascii

I believe that this might be the most informative of the options. It gives you all the juicy details of what key it is your are pressing.

showkey -a

This shows not only the letter your are pressing but also the associated decimal, octal, and hex values of the key press. I mostly just want to see the letter I am pressing but the other things are cool too.

Note that this option will not timeout on its own, you will have to press CTRL+D to exit the program.

Scancodes

The -s option shows the raw scancodes.

showkey -s

What seems to be odd is that sometimes it splits the codes of a single key push into two lines. I don’t know why nor have I investigated it. Maybe it’s something I am doing wrong?

Keycodes

This is also the default option and shows the raw keycode. You’ve already seen this one as it is the most basic.

showkey -k

Timeout

The Default timeout is 10 seconds for the options but if you would like to alter it up or down, it is easily accomplished with the -t option and an associated time in seconds. In this case showkey will timeout after 5 seconds.

showkey -t 5

Other than the -a option, you can tack on -s or -k options to get the timeout of your choosing.

Final Thoughts

This is a little thing that helped me figure out an issue I was having with my keyboard. It turned out that I was a bit negligent and I discovered that my secondary keyboard was pressed up against my IMSAI 8080 Replica beneath my desk. It was a silly thing that derailed my day for about 20 minutes but now I have a new tool to debug or investigate input.

References

https://kbd-project.org/
https://www.geeksforgeeks.org/showkey-command-in-linux-with-examples


Discover more from CubicleNate.com

Subscribe to get the latest posts sent to your email.


Comments

3 responses to “showkey | Examine Keyboard Codes”

  1. so what was causing the problem of [[

    1. A secondary keyboard that I use was leaning up against something that was causing it to register a press. So, it was due to my own negligence. There was nothing wrong.

Leave a Reply

Discover more from CubicleNate.com

Subscribe now to keep reading and get access to the full archive.

Continue reading