![]() ![]() | |
For example, if you want to create a keyboard shortcut, Control+7, for a button with the instance name myButton, you would do the following:
function myOnPress() {
trace( "hello" );
}
function myOnKeyDown() {
if (Key.isDown(Key.CONTROL) && Key.getCode() == 55) // 55 is key code for 7
{
Selection.setFocus( myButton );
myButton.onPress();
}
}
var myListener = new Object();
myListener.onKeyDown = myOnKeyDown;
Key.addListener( myListener );
myButton.onPress = myOnPress;
myButton._accProps.shortcut = "Ctrl+7"
Accessibility.updateProperties();
Note: The example assigns the keyboard shortcut Control+7 to a button with an instance name of myButton, and makes information about the shortcut available to screen readers. In this example, when you press Control+7 the myOnPress function displays the text "hello" in the Output panel. See Key.addListener().
![]() ![]() | |