Keystroke Client Event Script - KeyCode Hex Values

Thanks for your help @PGriffith, I was able to successfully attach the event dispatcher and find some usable Key Codes through trial and error :slight_smile:
The strange codes reported in Cherry Designer were actually for some common utility keys: Home, Insert, etc… I’m guessing their driver handles the mapping to the proper code?

I placed this code in the action event script of a button on a test page:

from java.awt import KeyboardFocusManager, KeyEventDispatcher

class printKeys(KeyEventDispatcher):
	def dispatchKeyEvent(self, event):
		try:
			print 'got key event: ' + str(event)
			return false
		except:
			pass
	
kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager()
kfm.addKeyEventDispatcher(printKeys())

I eventually found the range of hex codes that map to the F13+ keys, which is suitable for our usage.
For any future searchers: if you don’t include the try block and your event code errors out, you’ll break the key event handler stack and lose the use of your keyboard in the designer :upside_down_face:

1 Like