Screenkey is a screencast tool that displays the keys you pressed. You can get more details from https://gitlab.com/screenkey/screenkey.
Screenkey
Here is the configuration I use frequently.
screenkey -p top -s small --mods-mode mac -f DejaVu --opacity 0.3