mnemonic([key])

Class: Menu. Method inherited from MenuItem.

Description:

Gets or sets the mnemonic (keyboard shortcut key) for menu item type of components: Menu, MenuItem, CheckBoxMenuItem, RadioButtonMenuItem. It's not same as setting accelerator(...).
A mnemonic allows users to activate the menu item using the keyboard (typically Alt + key).

NOTE: Not all systems and UIs show underline under mnemonic character. Some systems only show it after Alt key was pressed.

Parameters:

Name Type Description

[key]

number | string | null

A key code integer or a single ASCII character representing the mnemonic key (case-insensitive). If omitted, acts as a getter. To clear mnemonic, pass 0, "", or null.

Returns:

If called without arguments, returns the current mnemonic key code integer. If called with an argument, returns this instance object for chaining.

Type: number | MenuItem

Examples:

menuItem.text("Quit").mnemonic("q"); // Makes letter Q to be used as the keyboard shortcut key
menuItem.mnemonic(""); // clears the mnemonic