Put the following code into the on_key action of a lineedit field:
Example 5.13. Reacting on keyboard input
key=hk_this.key() print "on_key=(",key.key(),")(",key.text(),")" if key.state()&key.state_ctrl: print "ctrl" if key.state()&key.state_shift: print "shift" if key.state()&key.state_alt: print "alt" if key.key()==key.key_F5: show_warningmessage("F5 pressed. This will be ignored") key.set_accept_key(False) if key.key()==key.key_M and key.state()&key.state_ctrl: show_warningmessage("ctrl m pressed")
when the on_key action is triggered an object of type hk_key is created and can be called via hk_this.key(). If you set the hk_key.set_accept_key() method to 'False', the key will not be accepted as input.