Keystroke Client Event Script - KeyCode Hex Values

I’m attempting to setup a Cherry LPOS g86-71400 keyboard to act as a custom operator keyboard within Ignition. The end goal is to mimic the functionality of the existing Honeywell control system that Ignition is replacing, which allows quick access to certain windows via dedicated keys.

This Cherry keyboard has a set of re-legendable, re-mapable keys. I can configure specific hex codes, or a macro of several codes, to any key using the Cherry Designer software. The keyboard configuration is then written to the board firmware.

When setting up a Keystroke Client Event Script, you can only select by the keycode or the character (plus modifiers). The keycode selection list seems to match the corresponding java Key Code Enum:

I’d like to make use of some dead keycodes, but can’t locate the matching hex values that I need to assign to my keyboards keys. Is there a listing of what hex values the Java KeyCode items map to? Or is there a way using reflection to find those hex codes with a script?

You could check against the constant values in java.awt.event.KeyEvent:

1 Like

Thanks for the link, that’s exactly what I was looking for!

Unfortunately, the constants I was aiming to use aren’t available in the Cherry Designer software and some codes that ARE available aren’t listed in the java constants… :confused:

Is it possible to attach a key event handler for a non-standard key code through scripting?
Thinking similar to this post though available across multiple desktops, not a specific component.

For reference, these are the hex and integer codes I’m looking to use:

0xe00e, 57358
0xe01c, 57372
0xe01d, 57373
0xe02ae037, 3760906295
0xe02b, 57387
0xe035, 57397
0xe038, 57400
0xe047, 57415
0xe048, 57416
0xe049, 57417
0xe04b, 57419
0xe04d, 57421
0xe04f, 57423
0xe050, 57424
0xe051, 57425
0xe052, 57426
0xe053, 57427
0xe05b, 57435
0xe05c, 57436
0xe05d, 57437
0xe11d45, 14753093
0xf1, 241
0xf2, 242
0xfc, 252
0xff, 255

I’m open to better ideas :slight_smile:

My initial plan was to map those custom keys to a combo of some modifiers + F keys. Like (LCtrl+F10) for the key above F10. After making that configuration change, however, it seemed the delay between keys in the macro was too much to register as one singular event, so Ignition couldn’t pick it up.

Try sending the higher hex values for weird key codes, and see if you can catch them with a KeyboardFocusManager hook:

  .addKeyEventDispatcher(new KeyEventDispatcher() {
      public boolean dispatchKeyEvent(KeyEvent e) {
        System.out.println("Got key event!");
        return false;

You’ll have to translate the Java to Jython, but it’s not that hard - make a new Python class that inherits from KeyEventDispatcher and contains a dispatchKeyEvent function - you’ll need to import KeyboardFocusManager and KeyEventDispatcher from their respective Java packages as well.

1 Like

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):
			print 'got key event: ' + str(event)
			return false
kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager()

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