END
Other references:
awkhelp: https://unix.stackexchange.com/a/89641/114401- Where I learned about
cat /proc/bus/input/devices: https://stackoverflow.com/a/15052092/4561887
Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Visit Stack ExchangeStack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
Explore Stack InternalEND
awk help: https://unix.stackexchange.com/a/89641/114401cat /proc/bus/input/devices: https://stackoverflow.com/a/15052092/4561887END
awk help: https://unix.stackexchange.com/a/89641/114401cat /proc/bus/input/devices: https://stackoverflow.com/a/15052092/4561887I'd like to post a summary of the various tools I've just tested.
I began with this google search: linux see what key is being pressed, which brought me to the following places. Since they are either closed or off-topic, right here is the most-logical choice to post my summary.
Here is a bit of a summary of the best answers from each of those places. I need this info. so I can:
Tested on Linux Ubuntu 20.04.
screenkey
# Install it sudo apt update sudo apt install screenkey # run it screenkey # it now displays a massive black bar at the bottom of your main monitor # whenever you press any key, showing all keys as they are pressed! # kill it # first, find its PID ps aux | grep screenkey # Sample output: # $ ps aux | grep screenkey # gabriel 215523 2.9 0.3 972900 59364 ? Rl 10:27 0:00 /usr/bin/python3 /usr/bin/screenkey # gabriel 215635 0.0 0.0 9040 2388 pts/0 S+ 10:27 0:00 grep --color=auto screenkey # OR pgrep screenkey # Sample output: # $ pgrep screenkey # 215523 # now, kill that PID; ex: kill 215523 Where I first learned about this tool: https://askubuntu.com/a/30468/327339
sudo showkey
# show numeric keycode key presses and releases (use Ctrl + C to exit) sudo showkey # show hex scancodes (use Ctrl + C to exit) sudo showkey -s # show ASCII keycodes, including the actual letter or character pressed, # which is the most human-readable (use `Ctrl + D` to exit, NOT `Ctrl + C`!) sudo showkey -a Source:
https://www.keyboardtester.com/. Test your keys in the browser, and/or see if a key is stuck. Where I first learned about this tool: https://askubuntu.com/a/1197656/327339
xev. When done using it, it takes two steps to kill it:
Sources:
sudo evtest - a very low-level tool; appears to be what I need to work on USB HID devices (I think); works great!
# Install it sudo apt update sudo apt install evtest # Run it # First, find your keyboard /dev/input/event number manually sudo evtest # Then, press Ctrl + C to kill it after it prints out all the events; you # do NOT need to "Select the device event number" as it requests. Just hit # Ctrl + C. # Let's assume ours is "/dev/input/event4". # now, run the grab command with the above event number path sudo su -c 'sleep 1; timeout -k5 10 evtest --grab /dev/input/event4' # OR, if you know that `sudo evtest` only shows one output line with the # word "keyboard" in it, you can script the above two steps with this one # cmd like this. Notice that you can get a list of all input devices with # `cat /proc/bus/input/devices`, as is done at the start of this cmd: input_event_num="$(cat /proc/bus/input/devices \ | grep -B 1 -A 10 -i "keyboard" | awk 'NR==6 {print $4}')"; \ path_to_keyboard="/dev/input/$input_event_num"; \ sudo su -c "sleep 1; timeout -k5 10 evtest --grab $path_to_keyboard" Source:
END