Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/NightOwl07/rebar-hotkeys
https://github.com/NightOwl07/rebar-hotkeys
Last synced: 1 day ago
JSON representation
- Host: GitHub
- URL: https://github.com/NightOwl07/rebar-hotkeys
- Owner: NightOwl07
- Created: 2024-05-03T07:30:45.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2024-05-03T07:30:47.000Z (8 months ago)
- Last Synced: 2024-05-03T13:29:58.935Z (8 months ago)
- Language: TypeScript
- Size: 1.95 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# rebar-hotkeys
This is a script for Rebar that manages hotkeys with long-press detection.
### Features
* Binds hotkeys to callback functions.
* Detects long-presses for hotkeys with a configurable timeout.### Installation
This script requires the `Rebar` framework for alt:V.
1. Clone the repository in your `plugins` folder:
```bash
git clone https://github.com/nightowl07/rebar-hotkeys src/plugins/hotkeys
```### Usage
1. Get the API
```javascript
await alt.Utils.waitFor(() => useClientApi().isReady('hotkey-api'));
const hotkeyApi = useClientApi().get('hotkey-api')
```2. Use the `hotkeyApi` function to get access to the `addHotkey` and `removeHotkey` functions:
```javascript
// Example usage
hotkeyApi.addHotkey(84, (isLongPress) => {
if (isLongPress) {
console.log('T key long-pressed!');
} else {
console.log('T key pressed!');
}
});
```* `addHotkey(key, callback)`: Binds a hotkey identified by its key code to a callback function. The callback function receives a boolean argument indicating whether the key was held long enough to be considered a long-press.
* `removeHotkey(key)`: Removes the hotkey binding for the specified key code.### Configuration
* `longPressTimeout`: This variable defines the time (in milliseconds) after which a key press is considered a long-press. You can modify this value in the constructor of the `HotKeyManager` class.