# On Hotkey

{% hint style="danger" %}
Hotkeys are only recognized while the application is in focus to prevent scripts that can act as keyloggers.
{% endhint %}

```lua
function yourEvent(string_modifier, string_hotkey)
    --isFocused is where the application is focused or not
    --string modifier will contain all modifiers that are held.
    --control+alt+shift
    --hotkey will contain a string based on which key is pressed
    --example: pressing 8 would give: N8
end

return function()
    addEvent('hotkeyPress', 'yourEvent');
    keepAlive();
end
```

{% hint style="info" %}
Events are asynchronous coroutines.
{% endhint %}

{% hint style="danger" %}
Hotkeys are only available for clients running the windows operating system.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.streamavatars.com/lua-scripting-api/api-reference-and-tips/events/on-hotkey.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
