You can do it in the background with:
https://pavpanchekha.com/blog/emacs-keylogger.html
and periodically update the latency parameters to be just over your natural typing speed.