How to detect that a key is being pressed, not HAS been pressed earlier!??

Rune runed at stud.cs.uit.no
Wed Jan 28 20:03:45 CET 2004


Hey

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
  else
    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.

Any help is appriciated :)



More information about the Python-list mailing list