Ez Hot Keys provides events that you can listen to.
You can listen to events from the HotKeysManager
by using the on
method.
import { useHotKeysManagerContext } from "@ez-kits/hot-keys-react";
import { useEffect } from "react";
function MyComponent() {
const hotKeysManager = useHotKeysManagerContext();
useEffect(() => {
return hotKeysManager.on("hot-keys:trigger", (hotKeyInfo, event) => {
console.log("hot-keys:trigger", hotKeyInfo, event);
});
}, [hotKeysManager]);
return <div>My Component</div>;
}
hot-keys:trigger
Triggered when a hotkey is triggered.
IHotKeyInfo
. The hotkey info.string
. The hotkey.string
. Name of the scope where the hot key associated with.boolean
. If true, hot key will not be triggered if user is typing in input or textarea.boolean
. If false, hot key will not be triggered.boolean
. If true, hot key can be triggered repeatedly.KeyboardEvent
.hot-keys:trigger-error
Triggered when a hotkey is found but it cannot be triggered.
IHotKeyInfo
. The hotkey info.string
. The hotkey.string
. Name of the scope where the hot key associated with.boolean
. If true, hot key will not be triggered if user is typing in input or textarea.boolean
. If false, hot key will not be triggered.boolean
. If true, hot key can be triggered repeatedly.KeyboardEvent
.object
. The reason why the hotkey cannot be triggered.boolean
. The hotkey is disabled.boolean
. The hotkey is ignored because the user is typing in input or textarea.boolean
. Repeat is detected but hot key is not repeatable.hot-keys:register
Triggered when a hotkey is registered.
string
. The hot key that is registered.Omit<IHotKeyInfo, "hotKey">
. The hot key information.boolean
. If false, hot key will not be triggered.boolean
. If true, hot key will not be triggered if user is typing in input or textarea.boolean
. If true, hot key can be triggered repeatedly.HotKeyHandler
. The handler to call when the hot key is triggered.IHotKeyScopeInstance
. The scope that the hot key is registered in.hot-keys:unregister
Triggered when a hotkey is unregistered.
string
. The hotkey.IHotKeyScopeInstance
. The scope that the hot key is unregistered from.scopes:register
Triggered when a scope is registered.
IHotKeyScopeInstance
. The scope that is registered.scopes:unregister
Triggered when a scope is unregistered.
IHotKeyScopeInstance
. The scope that is unregistered.scopes:activate
Triggered when a scope is activated.
IHotKeyScopeInstance
. The scope that is activated.scopes:deactivate
Triggered when a scope is deactivated.
IHotKeyScopeInstance
. The scope that is deactivated.enabled
Triggered when the hotkeys manager is enabled.
No parameters.
disabled
Triggered when the hotkeys manager is disabled.
No parameters.