820
Chapter 14: Properties
See also
Movie
keyCode
Usage
-- Lingo syntax
_key.keyCode
// JavaScript syntax
_key.keyCode;
Description
Key property; returns the numerical code for the last key pressed. Read-only.
The returned value is the key’s numerical value, not the American National Standards Institute
(ANSI) value.
You can use
keyCode
to detect when the user has pressed an arrow or function key, which cannot
be specified by the
key
property.
Use the sample movie Keyboard Lingo to test which characters correspond to different keys on
different keyboards.
Example
This handler uses the Message window to display the appropriate key code each time a key
is pressed:
-- Lingo syntax
on enterFrame
keyDownScript = put(_key.keyCode)
end
// JavaScript syntax
function enterFrame() {
keyDownScript = put(_key.keyCode);
}
This statement checks whether the up arrow (whose key code is 126) was pressed and if it was,
goes to the previous marker:
-- Lingo syntax
if (_key.keyCode = 126) then
_movie.goPrevious()
end if
// JavaScript syntax
if (_key.keyCode == 126) {
_movie.goPrevious();
}
This handler checks whether one of the arrow keys was pressed and if one was, responds
accordingly:
-- Lingo syntax
on keyDown
case (_key.keyCode) of
123: TurnLeft
126: GoForward
Summary of Contents for DIRECTOR MX 2004-DIRECTOR SCRIPTING
Page 1: ...DIRECTOR MX 2004 Director Scripting Reference...
Page 48: ...48 Chapter 2 Director Scripting Essentials...
Page 100: ...100 Chapter 4 Debugging Scripts in Director...
Page 118: ...118 Chapter 5 Director Core Objects...
Page 594: ...594 Chapter 12 Methods...
Page 684: ...684 Chapter 14 Properties See also DVD...
Page 702: ...702 Chapter 14 Properties See also face vertices vertices flat...
Page 856: ...856 Chapter 14 Properties JavaScript syntax sprite 15 member member 3 4...
Page 1102: ...1102 Chapter 14 Properties...