Flash Player 6.
my_mc
.onKeyDown
None.
Nothing.
Event handler; invoked when a movie clip has input focus and a key is pressed. The onKeyDown
event is invoked with no parameters. You can use the Key.getAscii
and Key.getCode
methods to determine which key was pressed. You must define a function that executes when the event is invoked.
The movie clip must have input focus enabled and set in order for the onKeyDown
event to work. First, the focusEnabled
property must be set to true
for the movie clip. Then, the clip must be given focus. This can be done either by using the Selection.setFocus
method or by setting the tab key to navigate to the clip.
If the Selection.setFocus
method is used, the path for the movie clip must be passed to the Selection.setFocus
method. It is very easy for other elements to take the focus back once the mouse is moved.
The following example defines a function for the onKeyDown
method that sends a trace
action to the Output window:
my_mc.onKeyDown = function () { trace ("onKeyDown called"); };
The following example sets input focus:
MovieClip.focusEnabled = true; Selection.setFocus(MovieClip);