KeyCastr, an open-source keystroke visualizer.
brew cask install keycastr
In order to work, KeyCastr must be included in the list of applications with Accessibility API access, under the Security & Privacy system preferences.
To add KeyCastr to the list click the + button and select KeyCastr from the file system.
NOTE: If KeyCastr is already in the list, then click the − button and add KeyCastr again to be certain that the right application is chosen.
Also, KeyCastr needs your explicit permission to to monitor inputs. You can set this in the Input Monitoring section under the Security & Privacy system preferences.
To add KeyCastr to the list click the + button and select KeyCastr from the file system.
NOTE: 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: