Skip to content

Instantly share code, notes, and snippets.

@z404
Last active October 31, 2021 15:24
Show Gist options
  • Save z404/1f47b5cebb861030deed41b61d8ccecd to your computer and use it in GitHub Desktop.
Save z404/1f47b5cebb861030deed41b61d8ccecd to your computer and use it in GitHub Desktop.
Clickable Enter key using tkinter and pynput
from pynput.keyboard import Key, Controller
from tkinter import *
import time
keyboard = Controller()
top = Tk()
# top.geometry("200x100")
def func():
keyboard.press(Key.alt)
keyboard.press(Key.tab)
keyboard.release(Key.alt)
keyboard.release(Key.tab)
time.sleep(0.4)
keyboard.press(Key.enter)
keyboard.release(Key.enter)
b = Button(top, text="Return", command=func)
b.pack()
top.attributes('-topmost', True)
top.mainloop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment