How to detect that a key is being pressed, not HAS been pressed earlier!??
theller at python.net
Wed Jan 28 20:35:05 CET 2004
runed at stud.cs.uit.no (Rune) writes:
> I'm trying to build a gui application and need to know if the user is
> actually holding down the shift or ctrl key. That is, if the user
> currently is holding down the shift key. In pseudo code this will boil
> down to something like this:
> def test:
> if user presses shift:
> return SHIFT_IS_PRESSED
> elif user presses ctrl:
> return CTRL_IS_PRESSED
> return false
> It's important to notice here that I'm not interested if the user has
> already pressed shift or ctrl. I'm only interested in knowing if he is
> currently holding down one of these keys. (I have looked into msvcrt
> and the like but have found no answer..) The function should also work
> in both windows and Linux.
No idea about linux, but on windows you use win32api.GetKeyState().
More information about the Python-list