-1

There are events called 'onkeydown' and 'onkeyup' in Javascript. Can anyone please suggest the python equivalent of it?

2
  • 1
    possible duplicate of Detect key input in Python Commented Apr 30, 2015 at 11:17
  • 1
    The javascript events you are referring to are specific to web-browsers. In what context would your python code be running? Commented Apr 30, 2015 at 19:23

1 Answer 1

1

Without any external library, python can't provide GUI features, such as events handling. Listening to an event such onkeydown or onkeyup is thus impossible with the python sdl.

If you really want to react to these events, you must use an external library providing event-driven operations, such as the Qt binding PyQt, the TKinter module, or other libraries.

Sign up to request clarification or add additional context in comments.

8 Comments

Detecting keystrokes isn't something specific to GUIs — which the OP never mentioned — and is quite possible without one.
@martineau So answer to the OP's question!
There's no single way to do it as it's an OS dependent operation.
@martineau So this discussion is just useless
No, I don't think it's useless. My point was that your statement that it's impossible in Python without a GUI library/module is incorrect.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.