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:triggerTriggered 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-errorTriggered 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:registerTriggered 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:unregisterTriggered when a hotkey is unregistered.
string. The hotkey.IHotKeyScopeInstance. The scope that the hot key is unregistered from.scopes:registerTriggered when a scope is registered.
IHotKeyScopeInstance. The scope that is registered.scopes:unregisterTriggered when a scope is unregistered.
IHotKeyScopeInstance. The scope that is unregistered.scopes:activateTriggered when a scope is activated.
IHotKeyScopeInstance. The scope that is activated.scopes:deactivateTriggered when a scope is deactivated.
IHotKeyScopeInstance. The scope that is deactivated.enabledTriggered when the hotkeys manager is enabled.
No parameters.
disabledTriggered when the hotkeys manager is disabled.
No parameters.