User Guide
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.