Home THE HYPERCARD CENTER

HyperTalk Reference
Home » HyperTalk Reference » Commands

Note: This is a work in progress and will be formatting errors. Read more about the project on the home page.

keyDown

keyDown char

The keyDown command simulates a key press from within a handler. It acts exactly as if the user pressed a character from the keyboard.

HyperCard sends the keyDown command to a field (if the insertion point is set) or to the current card when the user presses a key. The value passed to the parameter variable char corresponds to the key pressed.

You can handle the keyDown message as follows:

on keyDown theKey
   statements
end keyDown
Note: keyDown is not sent for characters typed using the type command.


Demo Script

on keyDownDemo
   -- The keyDown messages are handled in the script of this card
   show bkgnd field "demo field"
   put "Type any key..." into bkgnd field "demo field"
   put "Press the Return key to continue..." into ¬
   line 6 of bkgnd field "demo field"
 end keyDownDemo

Placeholders

char
An expression that yields a single character.

For example:

"a"
return
tab
numToChar(13)


statements
Any return-separated list of built-in commands, user-defined handlers, or keywords that are part of a message or function handler.

put "Hello world"   -- built-in command
get total(field 1)  -- function call
global HelpInfo     -- keyword


Related Topics

« import paint | HyperTalk Reference | lock »


Version 0.7b1 (March 24, 2022)

Made with Macintosh

Switch to Modern View

Home
The HyperCard Center
HyperTalk Reference
Home » HyperTalk Reference » Commands

Note: This is a work in progress and will be formatting errors. Read more about the project on the home page.

keyDown

keyDown char

The keyDown command simulates a key press from within a handler. It acts exactly as if the user pressed a character from the keyboard.

HyperCard sends the keyDown command to a field (if the insertion point is set) or to the current card when the user presses a key. The value passed to the parameter variable char corresponds to the key pressed.

You can handle the keyDown message as follows:

on keyDown theKey
   statements
end keyDown
Note: keyDown is not sent for characters typed using the type command.


Demo Script

on keyDownDemo
   -- The keyDown messages are handled in the script of this card
   show bkgnd field "demo field"
   put "Type any key..." into bkgnd field "demo field"
   put "Press the Return key to continue..." into ¬
   line 6 of bkgnd field "demo field"
 end keyDownDemo

Placeholders

char
An expression that yields a single character.

For example:

"a"
return
tab
numToChar(13)


statements
Any return-separated list of built-in commands, user-defined handlers, or keywords that are part of a message or function handler.

put "Hello world"   -- built-in command
get total(field 1)  -- function call
global HelpInfo     -- keyword


Related Topics

« import paint | HyperTalk Reference | lock »

Version 0.7b1 (March 24, 2022)

Made with Macintosh

Switch to Retro View