I have noticed a quirk with the " if event.type == gtk.gdk.KEY_PRESS: ". There are times where it will NOT trigger the event. AND there are NO errors triggered. When this hapens the only way to fix it is to reboot PP. After the reboot it works fine again untill it quits working again.
The " if event.type == gtk.gdk.KEY_RELEASE: " on the other hand NEVER fails to work.