---
title: "tinymce.Shortcuts"
description: "Contains logic for handling keyboard shortcuts."
canonical_url: "https://www.tiny.cloud/docs/tinymce/latest/apis/tinymce.shortcuts/"
md_url: "https://www.tiny.cloud/docs/tinymce/latest/apis/tinymce.shortcuts/index.md"
version: "latest"
last_updated: "2022-06-27T01:45:26Z"
tokens: 469
---
# tinymce.Shortcuts

Contains logic for handling keyboard shortcuts.

## Examples

```javascript
editor.shortcuts.add('ctrl+a', 'description of the shortcut', () => {});
editor.shortcuts.add('ctrl+alt+a', 'description of the shortcut', () => {});
// "meta" maps to Command on Mac and Ctrl on PC
editor.shortcuts.add('meta+a', 'description of the shortcut', () => {});
// "access" maps to Control+Option on Mac and shift+alt on PC
editor.shortcuts.add('access+a', 'description of the shortcut', () => {});

editor.shortcuts.add('meta+access+c', 'Opens the code editor dialog.', () => {
  editor.execCommand('mceCodeEditor');
});

editor.shortcuts.add('meta+shift+32', 'Inserts "Hello, World!" for meta+shift+space', () => {
  editor.execCommand('mceInsertContent', false, 'Hello, World!');
});
```

## Summary

### Methods

| Name | Summary | Defined by |
| --- | --- | --- |
| [add()](#add) | Adds a keyboard shortcut for some command or function. | `Shortcuts` |
| [remove()](#remove) | Remove a keyboard shortcut by pattern. | `Shortcuts` |

## Methods

### add()

```javascript
add(pattern: String, desc: String, cmdFunc: String | Function, scope: Object): Boolean
```
Adds a keyboard shortcut for some command or function.

#### Parameters

- `pattern (String)` - Shortcut pattern. Like for example: ctrl+alt+o.
- `desc (String)` - Text description for the command.
- `cmdFunc (String | Function)` - Command name string or function to execute when the key is pressed.
- `scope (Object)` - Optional scope to execute the function in.

#### Return value

- `Boolean` - true/false state if the shortcut was added or not.

### remove()

```javascript
remove(pattern: String): Boolean
```
Remove a keyboard shortcut by pattern.

#### Parameters

- `pattern (String)` - Shortcut pattern. Like for example: ctrl+alt+o.

#### Return value

- `Boolean` - true/false state if the shortcut was removed or not.
