# Keystroke Client Event Script - KeyCode Hex Values

**URL:** <https://forum.inductiveautomation.com/t/keystroke-client-event-script-keycode-hex-values/24613>\
**Category:** Ignition\
**Tags:** ignition79, python, scripting\
**Created:** [May 2, 2019, 8:03pm UTC](https://forum.inductiveautomation.com/t/keystroke-client-event-script-keycode-hex-values/24613 "2019-05-02T20:03:12Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![bfuson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bfuson/32/4597_2.png) [@bfuson](https://forum.inductiveautomation.com/u/bfuson)\
**Post date:** [May 3, 2019, 4:41pm UTC](https://forum.inductiveautomation.com/t/keystroke-client-event-script-keycode-hex-values/24613/6 "2019-05-03T16:41:58Z")

</div>

Thanks for your help @paul-griffith, I was able to successfully attach the event dispatcher and find some usable Key Codes through trial and error 🙂  
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:

```auto
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 🙃

---

_[View the full topic](https://forum.inductiveautomation.com/t/keystroke-client-event-script-keycode-hex-values/24613)._
