Whenever a standard (non-modifier) key is pressed or released, Director generates a
keyUp event. Only script attached to editable field sprites, frame scripts, and movie scripts receive keyboard events. All field sprites, even non-editable ones, can receive the standard sprite events (
mouseLeave, and so on) Refer to Chapter 7, for details on manipulating strings and text. See especially Example 7-7. Refer to Chapter 12, Text and Fields, in Director in a Nutshell for more details on working with fields.
Keyboard characters are sent automatically to an editable field sprite with keyboard focus, unless the
keyDown event is intercepted by an
onkeyDown handler in a sprite or castmember script first (or explicitly stopped in
the keyDownScript primary event handler).
The key being pressed “rides along” with the
keyDown event. If an editable field sprite receives the
keyDown event, the last key pressed will be added to the field. Non-editable fields, editable fields without keyboard focus, and non-field sprites do not receive
keyUp events. Rich text sprites can not be edited at run time. You must use field sprites for dynamic text.
keyDown handler will be called even when special characters, such as the arrow keys, are pressed. Simply
pass these onto the field sprite.
Fields will automatically recognize the arrow keys and Delete key to perform rudimentary editing (see "Editing Keys