Keyboard Event handler for RhinoPython (RhinoApp.KeyboardEvent)

Hi @ all,

i was wondering how i can define a function or if-statement which is called or proceded when a defined keyboard button (lets say “esc”) is hit?

something like:

import rhinoscriptsyntax as rs
import Rhino as rhi

if rhi.RhinoApp.EscapeKeyPressed is True:
    rs.MessageBox ("Center point of label was written to labelman_config.txt", buttons=0, title='Leaving Dialog')

But this does not work for me.
When I check what this element contains with
print "%s \n"%rhi.RhinoApp.EscapeKeyPressed

this gives me:
<IronPython.Runtime.Types.ReflectedEvent+BoundEvent object at 0x0000000000000080 [IronPython.Runtime.Types.ReflectedEvent+BoundEvent]>

I dont know how to handle this.

Thanks a lot for suggestions!

Kind regards
Mr Sinter

bump

SOLVED!

def escape_key_pressed(a, b):
    print "hello"
rhi.RhinoApp.EscapeKeyPressed += escape_key_pressed

handles ‘ESC’ keyboard input