HotKey.Register
---------------

Registers a global hot key based on the virtual key code and modifiers.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [HotKey](component_HotKey.md) | [5.0](newinversion50.md) | ✅ Yes | ✅ Yes | ❌ No | ❌ No | ❌ No |

MBS( "HotKey.Register"; Code; Modifiers { ; Exclusive; FileName; ScriptName; Local; Name; Tag } ) 

**MBS**( **"HotKey.Register";** /\* Registers a global hot key based on the virtual key code and modifiers. \*/  
**$Code**; /\* The virtual key code of the key to watch. Can be number or name of key.e.g. "F5" \*/   
**$Modifiers**; /\* The keyboard modifiers to look for. Can be number of text. Text can include command, shift, alpha, option and control.  
Added in 6.2 for Windows: RightShift, RightOption and RightControl.e.g. "control" \*/   
**$Exclusive**; /\* Optional; Pass 1 to register exclusive or 0 for non exclusive.e.g. 0 \*/   
**$FileName**; /\* Optional; The database file name where the script is located.e.g. "test.fmp12" \*/   
**$ScriptName**; /\* Optional; The script name.e.g. "MyScript" \*/   
**$Local**; /\* Optional; Pass 1 to have hotkey only run script if FileMaker is frontmost. Else pass 0 (default) to have a global hotkey.e.g. 0 \*/   
**$Name**; /\* Optional; The name for the hotkey.  
e.g. you can use this property to later decide in a script what to do.e.g. "Test Hotkey" \*/   
**$Tag**) /\* Optional; The tag for the hotkey.  
e.g. you can use this property to later decide in a script what to do. \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| Code | The virtual key code of the key to watch. Can be number or name of key. | "F5" |  |
| Modifiers | The keyboard modifiers to look for. Can be number of text. Text can include command, shift, alpha, option and control.   Added in 6.2 for Windows: RightShift, RightOption and RightControl. | "control" |  |
| Exclusive | Pass 1 to register exclusive or 0 for non exclusive. | 0 | Optional |
| FileName | The database file name where the script is located. | "test.fmp12" | Optional |
| ScriptName | The script name. | "MyScript" | Optional |
| Local | Pass 1 to have hotkey only run script if FileMaker is frontmost. Else pass 0 (default) to have a global hotkey. | 0 | Optional |
| Name | The name for the hotkey.   e.g. you can use this property to later decide in a script what to do. | "Test Hotkey" | Optional |
| Tag | The tag for the hotkey.   e.g. you can use this property to later decide in a script what to do. |  | Optional |

### Result

Returns reference or error.

### Description

Registers a global hot key based on the virtual key code and modifiers.   
Only one such combination can exist for the current application, i.e. multiple entities in the same application cannot register for the same hot key combination. The same hot key can, however, be registered by multiple applications. This means that multiple applications can potentially be notified when a particular hot key is requested.  
You can request exclusive registration for your process by passing 1 for exclusive parameter.  
Please use [HotKey.SetScript](HotKeySetScript.md) to assign a script for the hotkey or use parameters here.  
  
Added Windows support with version 5.2.  
  
MacOS key codes we map for you:   
Return, Tab, Space, Delete, Escape, Command, Shift, CapsLock, Option, Control, RightShift, RightOption, RightControl, Function, F17, VolumeUp, VolumeDown, Mute, F18, F19, F20, F5, F6, F7, F3, F8, F9, F11, F13, F16, F14, F10, F12, F15, Help, Home, PageUp, ForwardDelete, F4, End, F2, PageDown, F1, LeftArrow, RightArrow, DownArrow, UpArrow, Left, Right, Down, Up, A, S, D, F, H, G, Z, X, C, V, B, Q, W, E, R, Y, T, 1, 2, 3, 4, 6, 5, Equal, 9, 7, Minus, 8, 0, RightBracket, O, U, LeftBracket, I, P, L, J, Quote, K, Semicolon, Backslash, Comma, Slash, N, M, Period, Grave, KeypadDecimal, KeypadMultiply, KeypadPlus, KeypadClear, KeypadDivide, KeypadEnter, KeypadMinus, KeypadEquals, Keypad0, Keypad1, Keypad2, Keypad3, Keypad4, Keypad5, Keypad6, Keypad7, Keypad8, Keypad9.  
  
Windows key codes we map for you:   
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, LBUTTON, RBUTTON, CANCEL, MBUTTON, XBUTTON1, XBUTTON2, BACK, TAB, CLEAR, RETURN, SHIFT, CONTROL, MENU, PAUSE, CAPITAL, KANA, HANGEUL, HANGUL, JUNJA, FINAL, HANJA, KANJI, ESCAPE, CONVERT, NONCONVERT, ACCEPT, MODECHANGE, SPACE, PRIOR, NEXT, END, HOME, LEFT, UP, RIGHT, DOWN, LeftArray, UpArrow, RightArrow, DownArrow, SELECT, PRINT, EXECUTE, SNAPSHOT, INSERT, DELETE, HELP, LWIN, RWIN, APPS, SLEEP, NUMPAD0, NUMPAD1, NUMPAD2, NUMPAD3, NUMPAD4, NUMPAD5, NUMPAD6, NUMPAD7, NUMPAD8, NUMPAD9, MULTIPLY, ADD, SEPARATOR, SUBTRACT, DECIMAL, DIVIDE, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24, NUMLOCK, SCROLL, OEM\_NEC\_EQUAL, OEM\_FJ\_JISHO, OEM\_FJ\_MASSHOU, OEM\_FJ\_TOUROKU, OEM\_FJ\_LOYA, OEM\_FJ\_ROYA, LSHIFT, RSHIFT, LCONTROL, RCONTROL, LMENU, RMENU, BROWSER\_BACK, BROWSER\_FORWARD, BROWSER\_REFRESH, BROWSER\_STOP, BROWSER\_SEARCH, BROWSER\_FAVORITES, BROWSER\_HOME, VOLUME\_MUTE, VOLUME\_DOWN, VOLUME\_UP, MEDIA\_NEXT\_TRACK, MEDIA\_PREV\_TRACK, MEDIA\_STOP, MEDIA\_PLAY\_PAUSE, LAUNCH\_MAIL, LAUNCH\_MEDIA\_SELECT, LAUNCH\_APP1, LAUNCH\_APP2, OEM\_1, OEM\_PLUS, OEM\_COMMA, OEM\_MINUS, OEM\_PERIOD, OEM\_2, OEM\_3, OEM\_4, OEM\_5, OEM\_6, OEM\_7, OEM\_8, OEM\_AX, OEM\_102, ICO\_HELP, ICO\_00, PROCESSKEY, ICO\_CLEAR, PACKET, OEM\_RESET, OEM\_JUMP, OEM\_PA1, OEM\_PA2, OEM\_PA3, OEM\_WSCTRL, OEM\_CUSEL, OEM\_ATTN, OEM\_FINISH, OEM\_COPY, OEM\_AUTO, OEM\_ENLW, OEM\_BACKTAB, ATTN, CRSEL, EXSEL, EREOF, PLAY, ZOOM, NONAME, PA1, OEM\_CLEAR.  
  
  
With plugin version 6.0 or newer the script name can be a script ID number. In that case the plugin queries the script name for the given script ID. This allows to call scripts by ID and avoid problems if scripts are later renamed.  
  
Notice: FileMaker 19.2 adds a fmplugin extended privileges. If you have such an extended privileges to allow the plugin to trigger scripts, you need to grant permissions for it. If such a privilege is not defined, the plugin is allowed to trigger scripts. See FileMaker product documentation for details.  
### Examples

Register Control-F5:

 Set Field \[HotKeys::HotKey ID; MBS ("Hotkey.Register"; "F5"; "control")\]  
Set Variable \[$r ; Value:MBS ("[HotKey.SetScript](HotKeySetScript.md)"; HotKeys::HotKey ID; Get(FileName); "HotkeyAction")\]  
Register key 37 (L on US keyboard) with modifiers:

 Set Field \[HotKeys::HotKey ID; MBS ("Hotkey.Register"; 37; "shift-control-command-option")\]  
Set Variable \[$r ; Value:MBS ("[HotKey.SetScript](HotKeySetScript.md)"; HotKeys::HotKey ID; Get(FileName); "HotkeyAction")\]  
Register Control-F5 for showing/hiding data viewer:

 Set Variable \[$hotkey ; Value:MBS ("HotKey.Register"; "F5"; "control")\]  
Set Variable \[$r ; Value:MBS ( "[HotKey.SetEvaluate](HotKeySetEvaluate.md)"; $hotkey ; "MBS (\\"[Menubar.RunMenuCommand](MenubarRunMenuCommand.md)\\"; 49297)" )\]  
\# Mac &amp; Windows   
Register Control-F5 to write text file on desktop with content of data viewer:

 MBS ( "[HotKey.SetEvaluate](HotKeySetEvaluate.md)";   
 MBS ("HotKey.Register"; "F5"; "control");   
 "MBS ( \\"[Text.WriteTextFile](TextWriteTextFile.md)\\";   
 MBS ( \\"[FM.DataViewerContent](FMDataViewerContent.md)\\" );   
 MBS ( \\"[Path.AddPathComponent](PathAddPathComponent.md)\\";   
 MBS ( \\"[Folders.UserDesktop](FoldersUserDesktop.md)\\" );   
 \\"Data Viewer \\" &amp; substitute(substitute(Get(CurrentTimestamp); \\":\\"; \\"-\\"); \\"/\\"; \\"-\\") &amp; \\".txt\\" );   
 \\"UTF-8\\"   
 )"  
)  
// Mac only.  
Register Control-F6 to write current script a text file to desktop:

 MBS ( "[HotKey.SetEvaluate](HotKeySetEvaluate.md)";   
 MBS ("HotKey.Register"; "F6"; "control");   
 "MBS ( \\"[Text.WriteTextFile](TextWriteTextFile.md)\\";   
 MBS ( \\"[ScriptWorkspace.ScriptText](ScriptWorkspaceScriptText.md)\\" );   
 MBS ( \\"[Path.AddPathComponent](PathAddPathComponent.md)\\";   
 MBS ( \\"[Folders.UserDesktop](FoldersUserDesktop.md)\\" );   
 \\"Script \\" &amp; substitute(substitute(MBS ( \\"[ScriptWorkspace.CurrentTab](ScriptWorkspaceCurrentTab.md)\\" ); \\":\\"; \\"-\\"); \\"/\\"; \\"-\\") &amp; \\".txt\\" );   
 \\"UTF-8\\"   
 )"  
)  
// Mac only  
Register hotkey Control-F7 for Windows to insert XML snippet:

 MBS ( "[HotKey.SetEvaluate](HotKeySetEvaluate.md)"; Value: MBS ("HotKey.Register"; "F7"; "control");   
"Let (\[   
xml = \\"&lt;fmxmlsnippet type=\\\\\\"FMObjectList\\\\\\"&gt;&lt;Step enable=\\\\\\"True\\\\\\" id=\\\\\\"89\\\\\\" name=\\\\\\"# (comment)\\\\\\"&gt;&lt;Text&gt;loop counting up from 1 to $count &lt;/Text&gt;&lt;/Step&gt;&lt;Step enable=\\\\\\"True\\\\\\" id=\\\\\\"141\\\\\\" name=\\\\\\"Set Variable\\\\\\"&gt;&lt;Value&gt;&lt;Calculation&gt;&lt;!\[CDATA\[\\\\\\"/\* add count here \*/\\\\\\"\]\]&gt;&lt;/Calculation&gt;&lt;/Value&gt;&lt;Repetition&gt;&lt;Calculation&gt;&lt;!\[CDATA\[1\]\]&gt;&lt;/Calculation&gt;&lt;/Repetition&gt;&lt;Name&gt;$count &lt;/Name&gt;&lt;/Step&gt;&lt;Step enable=\\\\\\"True\\\\\\" id=\\\\\\"141\\\\\\" name=\\\\\\"Set Variable\\\\\\"&gt;&lt;Value&gt;&lt;Calculation&gt;&lt;!\[CDATA\[1\]\]&gt;&lt;/Calculation&gt;&lt;/Value&gt;&lt;Repetition&gt;&lt;Calculation&gt;&lt;!\[CDATA\[1\]\]&gt;&lt;/Calculation&gt;&lt;/Repetition&gt;&lt;Name&gt;$index &lt;/Name&gt;&lt;/Step&gt;&lt;Step enable=\\\\\\"True\\\\\\" id=\\\\\\"68\\\\\\" name=\\\\\\"If\\\\\\"&gt;&lt;Calculation&gt;&lt;!\[CDATA\[$index ≤ $count \]\]&gt;&lt;/Calculation&gt;&lt;/Step&gt;&lt;Step enable=\\\\\\"True\\\\\\" id=\\\\\\"71\\\\\\" name=\\\\\\"Loop\\\\\\"&gt;&lt;/Step&gt;&lt;Step enable=\\\\\\"True\\\\\\" id=\\\\\\"89\\\\\\" name=\\\\\\"# (comment)\\\\\\"&gt;&lt;Text&gt;your script steps here&lt;/Text&gt;&lt;/Step&gt;&lt;Step enable=\\\\\\"True\\\\\\" id=\\\\\\"89\\\\\\" name=\\\\\\"# (comment)\\\\\\"&gt;&lt;/Step&gt;&lt;Step enable=\\\\\\"True\\\\\\" id=\\\\\\"89\\\\\\" name=\\\\\\"# (comment)\\\\\\"&gt;&lt;Text&gt;next&lt;/Text&gt;&lt;/Step&gt;&lt;Step enable=\\\\\\"True\\\\\\" id=\\\\\\"141\\\\\\" name=\\\\\\"Set Variable\\\\\\"&gt;&lt;Value&gt;&lt;Calculation&gt;&lt;!\[CDATA\[$index + 1\]\]&gt;&lt;/Calculation&gt;&lt;/Value&gt;&lt;Repetition&gt;&lt;Calculation&gt;&lt;!\[CDATA\[1\]\]&gt;&lt;/Calculation&gt;&lt;/Repetition&gt;&lt;Name&gt;$index &lt;/Name&gt;&lt;/Step&gt;&lt;Step enable=\\\\\\"True\\\\\\" id=\\\\\\"72\\\\\\" name=\\\\\\"Exit Loop If\\\\\\"&gt;&lt;Calculation&gt;&lt;!\[CDATA\[$index &gt; $count \]\]&gt;&lt;/Calculation&gt;&lt;/Step&gt;&lt;Step enable=\\\\\\"True\\\\\\" id=\\\\\\"73\\\\\\" name=\\\\\\"End Loop\\\\\\"&gt;&lt;/Step&gt;&lt;Step enable=\\\\\\"True\\\\\\" id=\\\\\\"70\\\\\\" name=\\\\\\"End If\\\\\\"&gt;&lt;/Step&gt;&lt;/fmxmlsnippet&gt;\\";   
r = MBS ( \\"[Clipboard.SetFileMakerData](ClipboardSetFileMakerData.md)\\"; \\"ScriptStep\\"; xml );   
r = MBS ( \\"[RemoteControl.PressControlKey](RemoteControlPressControlKey.md)\\"; 1 );  
r = MBS ( \\"[RemoteControl.PressKey](RemoteControlPressKey.md)\\"; \\"v\\");  
r = MBS ( \\"[RemoteControl.PressControlKey](RemoteControlPressControlKey.md)\\"; 0 )  
\]; 1 )"; 0 )  
// for Windows  
### See also

- [HotKey.SetKeyUp](HotKeySetKeyUp.md)
- [HotKey.SetLocal](HotKeySetLocal.md)
- [HotKey.SetPermanent](HotKeySetPermanent.md)
- [HotKey.SetScript](HotKeySetScript.md)
- [HotKey.SetTag](HotKeySetTag.md)
- [HotKey.Unregister](HotKeyUnregister.md)
- [RemoteControl.PressKey](RemoteControlPressKey.md)
- [ScriptWorkspace.CurrentTab](ScriptWorkspaceCurrentTab.md)
- [ScriptWorkspace.ScriptText](ScriptWorkspaceScriptText.md)
- [Text.WriteTextFile](TextWriteTextFile.md)

### Release notes

- **Version 13.1**
    - Implemented local Hotkeys for Windows. So if [HotKey.Register](https://www.mbsplugins.eu/HotKeyRegister.shtml) is passed Local = 1, we run a different code path to monitor keyboard instead of registering global hotkey.

### Example Databases

- [Win Only/Search Scripts](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Win%20Only/Search%20Scripts.shtml#1ScriptAnchor_)
- [Win Only/Snippets for Windows](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Win%20Only/Snippets%20for%20Windows.shtml#3ScriptAnchor_)
- [Window/Popover CardWindow](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Window/Popover%20CardWindow.shtml#1ScriptAnchor_)

### Blog Entries

- [Goodies 28: Hide lines in Data Viewer](https://www.monkeybreadsoftware.com/filemaker/SyntaxColoring/28-HidelinesinDataViewer.shtml)
- [MBS FileMaker Advent calendar - Door 19 - Hot Keys](https://www.mbsplugins.de/archive/2024-12-19/MBS_FileMaker_Advent_calendar_/monkeybreadsoftware_blog_filemaker)
- [Define a hotkey to copy field name for layout objects in FileMaker](https://www.mbsplugins.de/archive/2024-11-09/Define_a_hotkey_to_copy_field_/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 13.1pr1](https://www.mbsplugins.de/archive/2023-02-01/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [Data Viewer extensions](https://www.mbsplugins.de/archive/2023-01-11/Data_Viewer_extensions/monkeybreadsoftware_blog_filemaker)
- [Insert snippet for FileMaker on Windows](https://www.mbsplugins.de/archive/2019-11-20/Insert_snippet_for_FileMaker_o/monkeybreadsoftware_blog_filemaker)
- [Define hot keys for functions in the FileMaker development](https://www.mbsplugins.de/archive/2019-11-15/Define_hot_keys_for_functions_/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

- [Ausgabe 1/2026, Seite 9](https://filemaker-magazin.de/neuigkeit/4312-Die-neue-Ausgabe-FMM_202601-steht-online)
- [Ausgabe 6/2020, Seite 29](https://filemaker-magazin.de/neuigkeit/4118-Appetithappen-FMM_202006)

This function checks for a license.

Created 4th February 2015 , last changed 25th February 2026

  
[HotKey.List](HotKeyList.md) - [HotKey.SetEnabled](HotKeySetEnabled.md)

[HTML Version](HotKeyRegister.shtml)