Skip to content

Instantly share code, notes, and snippets.

@ShivamJoker
Created October 28, 2019 08:45
Show Gist options
  • Save ShivamJoker/1f1aa73aaea7fde55b8b0eb2fc4b94f9 to your computer and use it in GitHub Desktop.
Save ShivamJoker/1f1aa73aaea7fde55b8b0eb2fc4b94f9 to your computer and use it in GitHub Desktop.
import sys
sys.path.append('..')
import keyboard
def print_pressed_keys(e):
line = ', '.join(str(code) for code in keyboard._pressed_events)
# '\r' and end='' overwrites the previous line.
# ' '*40 prints 40 spaces at the end to ensure the previous line is cleared.
print('\r' + line + ' '*40, end='')
keyboard.hook(print_pressed_keys)
keyboard.wait()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment