A modern keyboard shortcut library monorepo for React / Vue / Core utilities, supporting scoped binding, editor mode, and Electron scenarios.
Features • Installation • Quick Start • Packages & Versions • Monorepo Development • Publishing Process
- 🎯 Precise Shortcut Parsing: Supports key combinations, multi-key mapping, and cross-platform modifier key handling
- 🧠 Shared Core Module:
@keekuun/keymaster-coreunified management of parsing, matching, types, and utility functions - 🧩 Scoped Binding (scopedElement): Only responds to shortcuts within specified containers / editors
- ✏️ Editor Mode (editorMode): Automatically
preventDefault, suitable for editor-like products - 🖥️ Electron Mode (electronMode): Extension points reserved for desktop applications
- ⚛️ React Hook Wrapper:
useKeyBinding/useScopedKeyBinding/useEditorKeyBinding/useElectronKeyBinding - 🧪 Vue Composition API:
useKeyBindingVue/useScopedKeyBindingVue/useEditorKeyBindingVue/useElectronKeyBindingVue - 📦 TypeScript First: Complete declaration files, automatically generated by
vite-plugin-dts - 📚 Complete Documentation Site: Interactive documentation based on VitePress, supporting multi-version management and online demos
React Version:
npm install @keekuun/keymaster-react
# or
pnpm add @keekuun/keymaster-react
# or
yarn add @keekuun/keymaster-reactVue Version:
npm install @keekuun/keymaster-vue
# or
pnpm add @keekuun/keymaster-vue
# or
yarn add @keekuun/keymaster-vueCore Module (usually auto-installed as dependency, can also be used standalone):
npm install @keekuun/keymaster-coreimport { useKeyBinding } from '@keekuun/keymaster-react';
function App() {
useKeyBinding('ctrl+s', (event) => {
event.preventDefault();
console.log('Save operation');
});
return <div>Press Ctrl + S to save</div>;
}Scoped Binding Example:
import { useRef } from 'react';
import { useScopedKeyBinding } from '@keekuun/keymaster-react';
function Editor() {
const containerRef = useRef<HTMLDivElement | null>(null);
useScopedKeyBinding(
'ctrl+k',
() => {
console.log('Shortcut only works within container');
},
containerRef,
);
return <div ref={containerRef}>Ctrl + K only works here</div>;
}<script setup lang="ts">
import { useKeyBindingVue } from '@keekuun/keymaster-vue';
useKeyBindingVue('ctrl+s', (event) => {
event.preventDefault();
console.log('Save operation');
});
</script>
<template>
<div>Press Ctrl + S to save</div>
</template>Editor Mode Example:
<script setup lang="ts">
import { ref } from 'vue';
import { useEditorKeyBindingVue } from '@keekuun/keymaster-vue';
const editorRef = ref<HTMLTextAreaElement | null>(null);
useEditorKeyBindingVue(
'ctrl+s',
() => {
console.log('Save in editor, no browser default behavior');
},
editorRef.value || undefined,
);
</script>
<template>
<textarea ref="editorRef" rows="6" cols="40" />
</template>More examples (including Electron mode and advanced usage) can be found on the documentation site.
The current monorepo contains the following sub-packages:
@keekuun/keymaster-core: Core parsing / matching / type definition module@keekuun/keymaster-react: React Hook wrapper@keekuun/keymaster-vue: Vue Composition API wrapperkeymaster-docs: Documentation and example site based on VitePress
@keekuun/keymaster-core: v0.5.0 - npm@keekuun/keymaster-react: v0.5.0 - npm@keekuun/keymaster-vue: v0.5.0 - npm
- Online Documentation: https://keymaster-docs.vercel.app/
- React Documentation: https://keymaster-docs.vercel.app/react/
- Vue Documentation: https://keymaster-docs.vercel.app/vue/
- Core Documentation: https://keymaster-docs.vercel.app/core/
- Version Management: https://keymaster-docs.vercel.app/versions
@keekuun/keymaster-core (core module)
├── @keekuun/keymaster-react (depends on core)
└── @keekuun/keymaster-vue (depends on core)
Important Notes:
keymaster-coreis a runtime dependency ofkeymaster-reactandkeymaster-vue- When installing
@keekuun/keymaster-reactor@keekuun/keymaster-vue,@keekuun/keymaster-corewill be automatically installed - Only install
@keekuun/keymaster-coreseparately if you need to use core utility functions alone
This repository uses pnpm workspace to manage the multi-package structure. Root directory scripts:
pnpm build: Recursively build all packages (core / react / vue / docs)pnpm lint: Run ESLint checks for all packages and root directorypnpm lint:fix: Run ESLint auto-fix for all packages and root directorypnpm format: Check formatting with Prettierpnpm format:write: Auto-format with Prettierpnpm docs:dev: Start documentation dev server inapps/keymaster-docspnpm docs:build: Build all libraries + documentation sitepnpm docs:preview: Preview built documentation site
Before commit, Husky will automatically execute:
- ESLint auto-fix (all packages)
- Prettier auto-formatting
For detailed steps, see PUBLISH.md. Here's a brief overview:
- Confirm code passes
pnpm lint,pnpm test(if any),pnpm docs:build - Use
standard-versionto manage versions andCHANGELOG.md:pnpm release: Patch versionpnpm release:minor: Minor versionpnpm release:major: Major version
- Use publishing scripts to publish to npm:
pnpm publish:corepnpm publish:reactpnpm publish:vue- Or
pnpm publish:allto publish all three packages at once
- Push code and tags, Vercel will automatically trigger documentation site update
- Repository: https://github.com/Keekuun/keymaster
- Issue Reports / Feature Suggestions: Create entries in GitHub Issues
- Usage Questions & API Details: Refer to documentation site https://keymaster-docs.vercel.app/