Flash CS3  |  Go to CS4 Help

Create and name a keyboard shortcut

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

To create a keyboard shortcut, write ActionScript code for an object. If you provide a keyboard shortcut for an input text field or button, you must also use the ActionScript Key class to detect the key the user presses during Flash content playback. See Key in the ActionScript 2.0 Language Reference. See Capturing keypresses in Learning ActionScript 2.0 in Adobe Flash.

Select the object and add the name of the keyboard shortcut to the Accessibility panel so the screen reader can read it.

Test your Flash content with multiple screen readers. Keyboard shortcut functionality also depends on the screen reader software used. The key combination Control+F, for example, is a reserved keystroke for both the browser and the screen reader. The screen reader reserves the arrow keys. Generally, you can use the 0 to 9 keys on the keyboard for keyboard shortcuts, however, screen readers increasingly use even these keys.

Create a keyboard shortcut

  1. On the Stage, select the button or input text field to create a keyboard shortcut for.
  2. Select Window > Other Panels > Accessibility.
  3. In the Shortcut field, type the name of the keyboard shortcut, using the following conventions:
    • Spell out key names, such as Control or Alt.

    • Use capital letters for alphabetic characters.

    • Use a plus sign (+) between key names, with no spaces (for example, Control+A).

Important: Flash does not check that the ActionScript to code the keyboard shortcut was created.

Map Control+7 to myButton instance

  1. Select the object on the Stage, display the Accessibility panel, and in the Shortcut field, type Control+7 .
  2. Enter the following ActionScript 2.0 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 Control+7 keyboard shortcut 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.


Comments

Comments are no longer accepted for Flash CS3. Flash CS4 is the current version. To discuss Flash CS3, please use the Adobe forum.