ENTRY | DOWNLOAD | MANUAL | ONGOING | |
onKeyUp, onKeyDown()Methods that are called when a key on the keyboard is pressed or released, respectively. These event handler methods are fired in the world. As for most events, an event object is made available for them which, in case of the keyboard events, holds the key which was pressed in event.key. class Atlantis(World): def onKeyUp(self, event): pass def onKeyDown(self, event): pass Relevant examples: keyboard.py , ALL In Contextclass Atlantis(World): def onKeyDown(self, event): print 'A key has been pressed.' if event.key == ord('k'): print 'A "k" has been pressed.' #by ascii value if event.key == 98: print 'A "b" has been pressed.' def onKeyDown(self, event): print 'the following key has been released:' print chr(event.key) |
|
Initiated by Stephan Hechenberger Thanks to CADRE's 103 |