Creating a keyboard shortcut

You can create a keyboard shortcut for an object, such as a button, so users can quickly navigate to it without listening to the contents of an entire page. For example, you can create a keyboard shortcut so users can quickly navigate to a menu, a toolbar, the next page, or a submit button.

Two steps are required to create a keyboard shortcut:

Keyboard shortcut functionality also depends on the screen reader software used. Make sure to test your Flash content with multiple screen readers. The key combination Control+F, for example, is a reserved keystroke for both the browser and the screen reader. The arrow keys are also reserved by the screen reader. Generally, you can use the keys 0-9 on the keyboard for keyboard shortcuts. However, even these keys are increasingly used by screen readers, so it is very important to test your keyboard shortcuts. See Testing accessible content.

To indicate the name of a keyboard shortcut for the screen reader:

  1. On the Stage, select the button or input text field for which you want to create a keyboard shortcut.
  2. Do one of the following:
  3. In the Shortcut field, type the name of the keyboard shortcut, using the following conventions:

Keyboard shortcut example

To create a keyboard shortcut, Control+7, for a button with the instance name myButton, you would do the following:

  1. Select the object on the Stage, display the Accessibility panel, and in the Shortcut field, type Control+7.
  2. Enter the following code in the Actions panel:
    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 addListener (IME.addListener method) in ActionScript 2.0 Language Reference.


Version 8

 

Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flash/8/main/00000890.html