xev
A tiny X program that opens a window and prints every event that reaches it — the right tool when a key isn't doing what it should.
X talks to its clients through events: key presses, pointer motion, focus changes, resizes, windows becoming visible. xev prints them in plain text to the terminal, with keycode, keysym, modifiers and timestamp. Anyone remapping a multimedia key with xmodmap or XKB almost always started here, because it was the easiest way to find out what X actually called the key.
With -id it can listen to another program's window, which makes it handy for debugging window managers and focus problems. Its sibling xprop shows the properties set on a window rather than what happens to it. On Wayland, wev plays the same role, with the caveat that it can only see its own window.