0

When using python with the keyboard module is there a way I can use enter to execute something within a program?

vvvvv
  • 25,404
  • 19
  • 49
  • 81

1 Answers1

0

Use keyboard.add_hotkey to call the foobar function when pressing Enter.

import keyboard

def foobar():
    print("foo bar") 

keyboard.add_hotkey("enter", foobar)
keyboard.wait()

Source from the documentation.

vvvvv
  • 25,404
  • 19
  • 49
  • 81