Keyboard event scope

I’m probably overlooking something rather basic. I’ve written a few example lines of code to illustrate my question. How can I register a keyboard event’s scope to include the 3D window. Draw.Register seems to work only when the mouse cursor is in the Python window. Example code attached. I’d like to be able to PupMenu “You pressed the E-Key.” when the cursor is in the 3D window. Thanks in advance. Doug.

#!BPY 
from Blender import Draw 
     
actions = {Draw.ESCKEY : 'Draw.Exit()', 
    Draw.EKEY : 'Draw.PupMenu("You press the E-Key.")'} 
 
def builtin_event(evt, val):    # the function to handle input events 
    if actions.has_key(evt):  exec(actions[evt]) 
 
Draw.Register(None, builtin_event, None)  # registering the 3 callbacks 

Check out the BPy API documentation for spacehandlers.

/Nathan