sorry for bump, hope this helps though
bind( device , action , [ modifier , mod... ] , command )
Purpose
Use the bind method to associate a function to a keystroke or other device input.
Syntax
device - Name of the device to bind the command to (see 'Device Table' below).
action - Name of the action to watch for(see 'Action Table' below).
modifier – Special modifiers (mouse only), such as dead spot, etc.
command - The function to be called on make and break.
Returns
No return value.
Notes
The command bound via the bind function must be specified as a flat name with no elipses
or semi-colon termination and will be called on make and break events (i.e. key press and
release for a mapped key).
Args:
Warning: When a function is bound to a keystroke or other device input, and no other
versions of the binding are provided, the function will be called even if a modifier key
like CTRL, ALT, or SHIFT is also pressed. For clarification, see 'Bind Sample' example
below.
In your case:
actionmap.bind(keyboard0, Z, , , function(););
however... I don't think it is possible to make it so that this ONLY works while a specific GUI is open....