Matjaž Meža
Matjaž Meža

Reputation: 47

Detect enter key pressed python

is there a way to detect if ENTER is pressed with python? I was able to detect letters with win32api using win32api.GetAsyncKeyState(ord('H')) , but couldn't do the same with enter. I need to run the code on windows. Thanks.

Upvotes: 0

Views: 1295

Answers (1)

Yaroslav Kutsela
Yaroslav Kutsela

Reputation: 11

You can use keyboard lib.

pip3 install keyboard

import keyboard

if keyboard.read_key() == "enter":
    ...

https://github.com/boppreh/keyboard

Upvotes: 1

Related Questions