MenuItem.SetKeyEquivalent
-------------------------

Sets the receiver's unmodified key equivalent.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [Menu](component_Menu.md) | [4.1](newinversion41.md) | ✅ Yes | ❌ No | ❌ No | ❌ No | ❌ No |

MBS( "MenuItem.SetKeyEquivalent"; Item; Text ) 

**MBS**( **"MenuItem.SetKeyEquivalent";** /\* Sets the receiver's unmodified key equivalent. \*/  
**$Item**; /\* The reference to the menu item. Please create one with [MenuItem.CreateMenuItem](MenuItemCreateMenuItem.md) or [MenuItem.CreateSeparator](MenuItemCreateSeparator.md). \*/   
**$Text**) /\* A string containing a character code representing a keyboard key. If you want to remove the key equivalent from a menu item, pass an empty string.e.g. "T" \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| Item | The reference to the menu item. Please create one with [MenuItem.CreateMenuItem](MenuItemCreateMenuItem.md) or [MenuItem.CreateSeparator](MenuItemCreateSeparator.md). | $item |
| Text | A string containing a character code representing a keyboard key. If you want to remove the key equivalent from a menu item, pass an empty string. | "T" |

### Result

Returns OK or error.

### Description

Sets the receiver's unmodified key equivalent.  
This method considers the case of the letter passed to determine if it has a Shift modifier added. That is, "w" sets the key equivalent to Command-w, while "W" is Command-Shift-w. You use [MenuItem.SetKeyEquivalentModifierMask](MenuItemSetKeyEquivalentModifierMask.md) to set the appropriate mask for the modifier keys for the key equivalent.  
### Examples

Add menu item with key ⇧⌘T:

 # set useful constants:   
Set Variable \[$ShiftKeyMask ; Value:131072\]  
Set Variable \[$ControlKeyMask ; Value:262144\]  
Set Variable \[$AlternateKeyMask ; Value:524288\]  
Set Variable \[$CommandKeyMask ; Value:1048576\]  
  
\#now make menu entry   
Set Variable \[$item ; Value:MBS ("[MenuItem.CreateMenuItem](MenuItemCreateMenuItem.md)"; "With Key Equivalent")\]  
Set Variable \[$r ; Value:MBS ("MenuItem.SetKeyEquivalent"; $item ; "T")\]  
Set Variable \[$r ; Value:MBS ("[MenuItem.SetKeyEquivalentModifierMask](MenuItemSetKeyEquivalentModifierMask.md)"; $item ; $ShiftKeyMask + $CommandKeyMask )\]  
Set Variable \[$r ; Value:MBS ("[Menu.AddItem](MenuAddItem.md)"; $menu ; $item )\]  
### See also

- [Menu.AddItem](MenuAddItem.md)
- [MenuItem.CreateMenuItem](MenuItemCreateMenuItem.md)
- [MenuItem.CreateSeparator](MenuItemCreateSeparator.md)
- [MenuItem.GetKeyEquivalent](MenuItemGetKeyEquivalent.md)
- [MenuItem.GetUserKeyEquivalent](MenuItemGetUserKeyEquivalent.md)
- [MenuItem.SetKeyEquivalentModifierMask](MenuItemSetKeyEquivalentModifierMask.md)

### Example Databases

- [Menu/Popup Menu](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Menu/Popup%20Menu.shtml#2ScriptAnchor_)

This function checks for a license.

Created 18th August 2014 , last changed 15th April 2015

  
[MenuItem.SetItalic](MenuItemSetItalic.md) - [MenuItem.SetKeyEquivalentModifierMask](MenuItemSetKeyEquivalentModifierMask.md)

[HTML Version](MenuItemSetKeyEquivalent.shtml)