Something. Sort of.
There is xev that outputs all input events, both keyboard and mouse. I believe xev is generally available if not already present to all linux distributions.
But "all" input events gives a confusing mess! To focus on keyboard keys -
You can pipe xref output to grep to isolate keypresses.
------------------------------------------------------------------------
xev | gawk -F"," '/keycode/{if($0!=l)print $2,$3;l=$0;}'
------------------------------------------------------------------------
I would copy and paste that difficult one liner to your shell to see if it serves you.
That grep expression focuses on (I think!) what you want. It pulls and presents data from the "keycode" lines only.
- You open xev in a terminal window.
- Notice that xev opens it's own gui window.
- xev then outputs all linux input events happening to it's window to your terminal.
- Events occurring outside the xev window are ignored.
- The gawk utility ignores (hides) all the action except for key presses.
- Press {ctrl}c in your terminal to quit xref
- Higher functions (F1-F12, Print Screen) preempt xev and do their own thing. xev doesn't see these. Unless, of course, the Fn key does nothing.
The complex grep expression here is almost more than I can handle. If I needed more polish I would have to build a python wrapper around xev. But it does serve me. And I don't type that hot mess over and over. I alias it in my bash shells.