How to: Assign Access Keys and Keyboard Shortcuts
As you create a menu system, you should consider ease of access to the system, and you must assign tasks to the system. You must give menus and menu items tasks to perform, such as displaying forms, toolbars, and other menu systems. You should define access keys to permit entry to the menu system. You can also add keyboard shortcuts and enable or disable menu items for more control.
Assigning Access Keys
Well-designed menus have access keys for quick keyboard access to the menu functionality. The access key is represented by the underlined letter in the menu title or menu item. For instance, the Visual FoxPro File menu uses "F" as its access key.
If you don't assign an access key to a menu title or menu item, Visual FoxPro automatically assigns the first letter as the access key. For example, the Customer menu created previously didn't have a defined access key. Accordingly, Visual FoxPro assigned the first letter (C) as the access key.
To specify the access key for a menu or menu item
Type \< to the left of the letter you want as the access key.
For example, to set the access key to "u" in the Customer menu title, replace Customer with C\<ustomer in the Prompt column.
Note
If an access key for your menu system doesn't work, look for duplicate access keys.
Assigning Keyboard Shortcuts
In addition to assigning access keys, you can specify keyboard shortcuts for menus or menu items. As with access keys, keyboard shortcuts let you choose a menu or menu item by holding down one key while pressing another. The difference between access keys and keyboard shortcuts is that you can use a keyboard shortcut to choose a menu item without first displaying its menu.
Keyboard shortcuts for Visual FoxPro menu items are combinations of the CTRL or ALT key and another key. For instance, you can create a new file in Visual FoxPro by pressing CTRL+N.
To specify a keyboard shortcut for a menu or menu item
In the Prompt column, select the appropriate menu title or menu item.
Choose the button in the Options column to display the Prompt Options dialog box.
In the Key Label box, press a key combination to create a keyboard shortcut.
If a menu item doesn't have a keyboard shortcut, Visual FoxPro displays "(press the key)" in the Key Label box.
In the Key Text box, add the text you want to appear beside the menu item.
By default, Visual FoxPro repeats the keyboard shortcut from the Key Label box in the Key Text box. However, you can change the text in the Key Text box if you want your application to display different text. For example, if both the Key Label and Key Text were CTRL+R, you could change the Key Text value to ^R.
Note
CTRL+J is an invalid keyboard shortcut because it is used to close certain dialog boxes in Visual FoxPro.
See Also
Tasks
How to: Include Menus in an Application
How to: Enable and Disable Menu Items