KeyCastr, an open-source keystroke visualizer.
which cask || brew tap caskroom/cask # Get cask if you don't already have it
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.