KeyCastr, an open-source keystroke visualizer.
brew install --cask keycastr
KeyCastr requires access to the macOS Accessibility API in order to receive your key events and broadcast the keystrokes you are interested in.
On newer versions of macOS (10.15+) there is a new Input Monitoring menu under Security & Privacy within the System Preferences app, and KeyCastr will appear there automatically the first time you run it. Simply unlock this menu and check the box next to KeyCastr to enable it.
On older versions of macOS, or if for some reason the app doesn't appear under the Input Monitoring menu (or if you want to pre-enable it) then you may manually add it to the list of apps in the Accessibility menu.
To add KeyCastr to the list click the + button and select KeyCastr from the file system.
If KeyCastr is already in the list, then click the − button and add KeyCastr again to be certain that the right application is chosen.
Make sure to check the "Display all keystrokes" checkbox if you would like to display more than just the modifier keys.
Alternatively, keep this box unchecked to only display modifier keys (e.g. ⇧ ⌃ ⌥ ⌘)
The default position is on the bottom left of your display. To modify the position of displayed keystrokes, click and drag the text like so: