keyPressed()
377
The following example displays information in cast member “field 2” about the music playing in
sound channel 1. If the music is not yet past cue point “climax”, the text of “field 2” is “This is the
beginning of the piece.” Otherwise, the text reads “This is the end of the piece.”
-- Lingo syntax
if not sound(1).isPastCuePoint("climax") then
member("field 2").text = "This is the beginning of the piece."
else
member("field 2").text = "This is the end of the piece."
end if
// JavaScript syntax
var cmx = sound(1).isPastCuePoint("climax");
if (cmx != 1) {
member("field 2").text = "This is the beginning of the piece.";
} else {
member("field 2").text = "This is the end of the piece.";
}
keyPressed()
Usage
-- Lingo syntax
_key.keyPressed({
keyCodeOrCharacter
})
// JavaScript syntax
_key.keyPressed({
keyCodeOrCharacter
});
Description
Key method; returns the character string assigned to the key that was last pressed, or optionally
whether a specified key was pressed.
If the
keyCodeOrCharacter
parameter is omitted, this method returns the character string
assigned to the last key that was pressed. If no key was pressed, this method returns an
empty string.
If the
keyCodeOrCharacter
is used to specify the key being pressed, this method returns
TRUE
if
that particular key is being pressed, or
FALSE
if not.
This method is updated when the user presses keys while in a
repeat
(Lingo) or
for
(JavaScript
syntax) loop. This is an advantage over the
key
property, which doesn’t update while in a
repeat
or
for
loop.
To test which characters correspond to different keys on different keyboards, use the Keyboard
Lingo sample movie.
Parameters
keyCodeOrCharacter
Optional. The key code or ASCII character string to test.
Summary of Contents for DIRECTOR MX 2004
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...