There are events called 'onkeydown' and 'onkeyup' in Javascript. Can anyone please suggest the python equivalent of it?
-
1possible duplicate of Detect key input in PythonMichel de Nijs– Michel de Nijs2015-04-30 11:17:50 +00:00Commented Apr 30, 2015 at 11:17
-
1The javascript events you are referring to are specific to web-browsers. In what context would your python code be running?ekhumoro– ekhumoro2015-04-30 19:23:19 +00:00Commented Apr 30, 2015 at 19:23
Add a comment
|
1 Answer
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.
8 Comments
martineau
Detecting keystrokes isn't something specific to GUIs — which the OP never mentioned — and is quite possible without one.
Spirine
@martineau So answer to the OP's question!
martineau
There's no single way to do it as it's an OS dependent operation.
Spirine
@martineau So this discussion is just useless
martineau
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.
|