RemoteControl.PressKey
----------------------

Presses a key.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [RemoteControl](component_RemoteControl.md) | [2.8](newinversion28.md) | ✅ Yes | ✅ Yes | ❌ No | ❌ No | ❌ No |

MBS( "RemoteControl.PressKey"; VirtualKey; ScanCode { ; down } ) 

**MBS**( **"RemoteControl.PressKey";** /\* Presses a key. \*/  
**$VirtualKey**; /\* The platform dependent virtual key code. Pass a number for a virtual key code or pass a string to let the plugin try to lookup the virtual key code.e.g. "a" \*/   
**$ScanCode**; /\* The platform dependent scan code. Pass a number for a scan code or pass a string to let the plugin try to lookup the virtual key code. If this parameter is missing, the virtual key code is used to lookup the scan code.e.g. "a" \*/   
**$down**) /\* Optional; Whether to press key down or release it. If parameter is missing the plugin will do both. \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| VirtualKey | The platform dependent virtual key code. Pass a number for a virtual key code or pass a string to let the plugin try to lookup the virtual key code. | "a" |  |
| ScanCode | The platform dependent scan code. Pass a number for a scan code or pass a string to let the plugin try to lookup the virtual key code. If this parameter is missing, the virtual key code is used to lookup the scan code. | "a" |  |
| down | Whether to press key down or release it. If parameter is missing the plugin will do both. |  | Optional |

### Result

Returns OK on success.

### Description

Presses a key.  
Codes are platform dependent. As a help we allow you to pass the character for the key as text and the plugin looks up virtual key code and scan code. But this lookup can fail. So please try all keys for your keyboard.  
  
Common key codes for MacOS:  
  
| Key | Hex KeyCode | Decimal KeyCode |
|---|---|---|
| a | 00 | 0 |
| b | 0B | 11 |
| c | 08 | 8 |
| d | 02 | 2 |
| e | 0E | 14 |
| f | 03 | 3 |
| g | 05 | 5 |
| h | 04 | 4 |
| i | 22 | 34 |
| j | 26 | 38 |
| k | 28 | 40 |
| l | 25 | 37 |
| m | 2E | 46 |
| n | 2D | 45 |
| o | 1F | 31 |
| p | 23 | 35 |
| q | 0C | 12 |
| r | 0F | 15 |
| s | 01 | 1 |
| t | 11 | 17 |
| u | 20 | 32 |
| v | 09 | 9 |
| w | 0D | 13 |
| x | 07 | 7 |
| y | 10 | 16 |
| z | 06 | 6 |
| 0 | 52 | 82 |
| 1 | 53 | 83 |
| 2 | 54 | 84 |
| 3 | 55 | 85 |
| 4 | 56 | 86 |
| 5 | 57 | 87 |
| 6 | 58 | 88 |
| 7 | 59 | 89 |
| 8 | 5B | 91 |
| 9 | 5C | 92 |
| F1 | 7A | 122 |
| F2 | 78 | 120 |
| F3 | 63 | 99 |
| F4 | 76 | 118 |
| F5 | 60 | 96 |
| F6 | 61 | 97 |
| F7 | 62 | 98 |
| F8 | 64 | 100 |
| F9 | 65 | 101 |
| F10 | 6D | 109 |
| F11 | 67 | 103 |
| F12 | 6F | 111 |
| F13 | 69 | 105 |
| F14 | 6B | 107 |
| F15 | 71 | 113 |
| Space | 31 | 49 |
| Tab | 30 | 48 |
| Home | 73 | 115 |
| Backspace | 33 | 51 |
| End | 77 | 119 |
| Page Up | 74 | 116 |
| Page Down | 79 | 121 |
| Delete | 75 | 117 |
| Help | 72 | 114 |
| Left | 7B | 123 |
| Right | 7C | 124 |
| Up | 7E | 126 |
| Down | 7D | 125 |
| = | 18 | 24 |
| - | 1B | 27 |
| \[ | 21 | 33 |
| \] | 1E | 30 |
| \\ | 2A | 42 |
| ´ | 32 | 50 |
| ' | 27 | 39 |
| ; | 29 | 41 |
| / | 2C | 44 |
| , | 2B | 43 |
| . | 2F | 47 |
| , | 2B | 43 |

  
On macOS the FileMaker application needs to have permissions to press keys. See system preferences, privacy and accessibility. Make sure FileMaker has a checkmark there.  
  
See virtual key codes for Windows here:  
<https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes>  
### Examples

Press a key

 MBS ( "RemoteControl.PressKey"; "a")  
Press return key on Mac:

 MBS ( "RemoteControl.PressKey"; 36; 13)  
Press cursor right key on Mac:

 MBS ( "RemoteControl.PressKey"; 124; 0 )  
Write Hello

 Set Variable \[ $r ; Value: MBS ("[RemoteControl.PressShiftKey](RemoteControlPressShiftKey.md)"; 1) \]   
Set Variable \[ $r ; Value: MBS ("RemoteControl.PressKey"; "H") \]   
Set Variable \[ $r ; Value: MBS ("[RemoteControl.PressShiftKey](RemoteControlPressShiftKey.md)"; 0) \]   
Set Variable \[ $r ; Value: MBS ("RemoteControl.PressKey"; "e") \]   
Set Variable \[ $r ; Value: MBS ("RemoteControl.PressKey"; "l") \]   
Set Variable \[ $r ; Value: MBS ("RemoteControl.PressKey"; "l") \]   
Set Variable \[ $r ; Value: MBS ("RemoteControl.PressKey"; "o") \]  
Press return with plugin looking up codes:

 Set Variable \[ $r ; Value: MBS ("RemoteControl.PressKey"; ¶) \]  
Press space key:

 Set Variable \[ $r ; Value: MBS ("RemoteControl.PressKey"; " ") \]  
### See also

- [HotKey.Register](HotKeyRegister.md)
- [RemoteControl.PressCommandKey](RemoteControlPressCommandKey.md)
- [RemoteControl.PressControlKey](RemoteControlPressControlKey.md)
- [RemoteControl.PressKeyLater](RemoteControlPressKeyLater.md)
- [RemoteControl.PressOptionKey](RemoteControlPressOptionKey.md)
- [RemoteControl.PressShiftKey](RemoteControlPressShiftKey.md)
- [Schedule.EvaluateAfterDelay](ScheduleEvaluateAfterDelay.md)

### Release notes

- **Version 14.5**
    - Fixed an edge case with swiss keyboard layout for [RemoteControl.PressKey](https://www.mbsplugins.eu/RemoteControlPressKey.shtml) function and the virtual key lookup.

### Example Databases

- [RemoteControl/Control Windows Calculator](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/RemoteControl/Control%20Windows%20Calculator.shtml#3ScriptAnchor_)
- [RemoteControl/Press keys](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/RemoteControl/Press%20keys.shtml#1ScriptAnchor_)
- [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_)

### Blog Entries

- [MBS FileMaker Plugin, version 14.5pr2](https://www.mbsplugins.de/archive/2024-10-07/MBS_FileMaker_Plugin_version_1/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)

This function checks for a license.

Created 18th August 2014 , last changed 23th August 2022

  
[RemoteControl.PressDialogButton.Clear](RemoteControlPressDialogButtonClear.md) - [RemoteControl.PressKeyLater](RemoteControlPressKeyLater.md)

[HTML Version](RemoteControlPressKey.shtml)