> For the complete documentation index, see [llms.txt](https://docs.uibakery.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.uibakery.io/how-tos/custom-code/implementing-custom-app-hotkeys.md).

# Implementing custom app hotkeys

In UI Bakery, you can implement custom hotkeys for your application if necessary. You can do this using UI Bakery actions and the [hotkeys-js](https://github.com/jaywcjlove/hotkeys-js) library. Check it out:point\_down:

1. Start by connecting the [hotkeys-js](https://github.com/jaywcjlove/hotkeys-js) library - navigate to the **Custom code** tab and add the following script tag:

```html
<script src="https://cdn.jsdelivr.net/npm/hotkeys-js@3.10.1/dist/hotkeys.min.js"></script>
```

{% hint style="info" %}
You can find more information on connecting and using external JavaScript libraries [here](/how-tos/data/connect-external-js-library.md#using-external-third-party-js-library).
{% endhint %}

2. Next, set up a **global** action to define the hotkeys:
   1. Click on the app area or select your current page in the *Pages* tab to access the **Settings** of the current page (right side panel).
   2. For the **On App Load/On Page Load** trigger, click *Create action.*
   3. Add a **JavaScript Code** action and define your hotkeys and action calls in the code, for example:

```javascript
hotkeys('E', function(event, handler){
  event.preventDefault();
  alert('E');
});
```

3. Now, test the hotkey - run the action, focus the app area, and press the **E keyboard key**.\
   This should open the browser alert.

{% hint style="warning" %}
The hotkeys will only work when the **app area is focused**. If the hotkeys don't work, try clicking on the app area to focus it.
{% endhint %}

You can also refer to [hotkeys-js documentation](https://github.com/jaywcjlove/hotkeys-js#defining-shortcuts) for additional information on defining hotkeys.

{% @arcade/embed flowId="Gao49XFZjvZEUtGSzENL" url="<https://app.arcade.software/share/Gao49XFZjvZEUtGSzENL>" %}

***

You can also further extend the code above and define a **hotkey-action pairing** assuming that you've already configured the actions that you'd like to trigger with the hotkeys, for example:

```javascript
hotkeys('ctrl+a,ctrl+b,r,f', async function (event, handler){
  switch (handler.key) {
    case 'ctrl+a':
      await actions.hotkeyA.trigger();
      break;
    case 'ctrl+b':
      await actions.hotkeyB.trigger();
      break;
    case 'r': 
      alert('you pressed r!');
      break;
    case 'f': 
      alert('you pressed f!');
      break;
  }
});
```

{% hint style="info" %}
Notice how this example utilizes the ability to call UI Bakery actions using *async/await syntax* with `await actions.hotkeyA.trigger();`. Refer to [this article](/concepts/actions/action-basics/use-actions.name.trigger.md) for more details on calling actions from code.
{% endhint %}

After defining and setting everything up, you need to reload the app to test the final setup. The hotkeys action will be executed upon app/page load, defining the hotkeys to activate the app's actions.

<figure><img src="https://837703843-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUX6zPRMFFK0yrTghj7cY%2Fuploads%2FqHasyt8MYt4PZ2GiHwWd%2FCleanShot%202025-03-24%20at%2018.36.32%402x-min.png?alt=media&amp;token=0e8d2970-da7a-4e32-954c-f659060a5f66" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.uibakery.io/how-tos/custom-code/implementing-custom-app-hotkeys.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
