
Research
Supply Chain Attack on Axios Pulls Malicious Dependency from npm
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.
@jalez/react-shortcuts-provider
Advanced tools
[](https://codecov.io/gh/jalez/react-shortcuts-provider) [](https://github.com/sponsors/jalez)
A React context/provider and utilities for managing keyboard shortcuts in your app. This library provides a decoupled, registry-based keyboard shortcuts system that allows components to register actions with specific key combinations without being tightly coupled to other components.
npm install @jalez/react-shortcuts-provider
import { ShortcutsProvider } from '@jalez/react-shortcuts-provider';
function App() {
return (
<ShortcutsProvider>
<YourMainComponent />
</ShortcutsProvider>
);
}
import { useEffect } from 'react';
import { registerShortcut, unregisterShortcut, DEFAULT_SHORTCUT_CATEGORIES } from '@jalez/react-shortcuts-provider';
function MyComponent() {
useEffect(() => {
// Register a shortcut
registerShortcut(
DEFAULT_SHORTCUT_CATEGORIES.NAVIGATION,
'my-action',
'Ctrl+M',
() => console.log('My action triggered!'),
'My custom action'
);
// Cleanup
return () => {
unregisterShortcut(DEFAULT_SHORTCUT_CATEGORIES.NAVIGATION, 'my-action');
};
}, []);
return <div>My Component</div>;
}
import { ShortcutsDisplay } from '@jalez/react-shortcuts-provider';
function MyApp() {
return (
<ShortcutsProvider>
<div>
<h1>My App</h1>
{/* Position the shortcuts display wherever you want */}
<ShortcutsDisplay className="absolute bottom-5 right-5" />
</div>
</ShortcutsProvider>
);
}
registerShortcut(category, name, keyCombo, action, description, enabled?, order?)Register a new keyboard shortcut.
category: Shortcut category (string)name: Unique name for the shortcut within its categorykeyCombo: Key combination (e.g., "Ctrl+F", "Shift+M", "Delete")action: Function to execute when triggereddescription: Human-readable descriptionenabled: Whether the shortcut is enabled (default: true)order: Display order (lower numbers appear first)unregisterShortcut(category, name)Remove a registered shortcut.
getAllShortcuts()Get all registered shortcuts across all categories.
The system supports various key combination formats:
"Ctrl+F" - Control + F (or Cmd+F on macOS)"Shift+Delete" - Shift + Delete"Alt+Tab" - Alt + Tab"Ctrl+Shift+Z" - Control + Shift + Z"F11" - Function key F11"Esc" - Escape keyDEFAULT_SHORTCUT_CATEGORIES = {
NAVIGATION: "navigation",
VIEW_SETTINGS: "viewSettings",
TOOLS: "tools",
EDITING: "editing",
CUSTOM: "custom",
}
useShortcutsRegistry()Access the shortcuts registry state:
const { shortcuts, getShortcuts, getAllShortcuts } = useShortcutsRegistry();
useShortcuts()Access shortcuts display state (requires ShortcutsProvider):
const { showShortcuts, toggleShortcuts } = useShortcuts();
useKeyboardShortcutHandler()Enable automatic keyboard event handling (used internally by ShortcutsManager).
ShortcutsProviderMain component that provides the complete shortcuts system:
<ShortcutsProvider initialShow={false}>
<YourApp />
</ShortcutsProvider>
ShortcutsDisplayComponent that displays registered shortcuts. Position it wherever you want:
<ShortcutsDisplay
showCategories={true}
maxShortcuts={20}
className="absolute bottom-5 right-5 z-50"
/>
Props:
showCategories: Whether to group shortcuts by category (default: true)maxShortcuts: Maximum number of shortcuts to show initially (default: 20)className: Additional CSS classes for positioning and stylingimport React, { useState, useEffect } from 'react';
import {
ShortcutsProvider,
ShortcutsDisplay,
registerShortcut,
unregisterShortcut
} from '@jalez/react-shortcuts-provider';
function App() {
const [showMessage, setShowMessage] = useState(false);
useEffect(() => {
registerShortcut(
'Examples',
'show-message',
'Ctrl+M',
() => setShowMessage(prev => !prev),
'Toggle a message',
true,
20
);
return () => {
unregisterShortcut('Examples', 'show-message');
};
}, []);
return (
<ShortcutsProvider>
<div className="min-h-screen p-8">
<h1>React Shortcuts Provider Demo</h1>
<ShortcutsDisplay className="absolute bottom-5 right-5" />
{showMessage && (
<div className="bg-blue-500 text-white p-4 rounded-lg">
Hello from keyboard shortcut!
</div>
)}
</div>
</ShortcutsProvider>
);
}
import { useEffect } from 'react';
import {
registerShortcut,
unregisterShortcut,
DEFAULT_SHORTCUT_CATEGORIES
} from '@jalez/react-shortcuts-provider';
function MyComponent() {
useEffect(() => {
// Navigation shortcuts
registerShortcut(
DEFAULT_SHORTCUT_CATEGORIES.NAVIGATION,
'next-item',
'ArrowDown',
() => navigateNext(),
'Navigate to next item'
);
// Editing shortcuts
registerShortcut(
DEFAULT_SHORTCUT_CATEGORIES.EDITING,
'delete-item',
'Delete',
() => deleteCurrentItem(),
'Delete current item'
);
// Tools shortcuts
registerShortcut(
DEFAULT_SHORTCUT_CATEGORIES.TOOLS,
'toggle-panel',
'Ctrl+P',
() => togglePanel(),
'Toggle side panel'
);
return () => {
unregisterShortcut(DEFAULT_SHORTCUT_CATEGORIES.NAVIGATION, 'next-item');
unregisterShortcut(DEFAULT_SHORTCUT_CATEGORIES.EDITING, 'delete-item');
unregisterShortcut(DEFAULT_SHORTCUT_CATEGORIES.TOOLS, 'toggle-panel');
};
}, []);
return <div>My Component</div>;
}
The library is fully typed with TypeScript. All functions and components include proper type definitions:
import type {
ShortcutEntry,
ShortcutCategory,
KeyCombination
} from '@jalez/react-shortcuts-provider';
This project uses:
# Development
npm run dev # Start development server
npm run build # Build the library
npm run preview # Preview the build
# Testing
npm run test # Run tests in watch mode
npm run test:run # Run tests once
npm run test:ui # Run tests with UI
npm run test:coverage # Run tests with coverage
# Linting
npm run lint # Run ESLint
src/
├── ShortCuts/
│ ├── components/ # React components
│ │ └── ShortcutsDisplay.tsx
│ │
│ ├── context/ # React context and hooks
│ │ ├── ShortcutsContext.tsx
│ │ ├── ShortcutsContextDef.ts
│ │ └── useShortcuts.ts
│ │
│ ├── registry/ # Core registry system
│ │ └── shortcutsRegistry.ts
│ │
│ ├── index.tsx # Component exports
│ └── shortcuts-exports.ts # Function and type exports
└── index.ts # Main library entry point
git checkout -b feature/amazing-feature)git commit -m 'Add some amazing feature')git push origin feature/amazing-feature)If you find this library helpful, please consider sponsoring me on GitHub! Your support helps me maintain and improve this project.
This project is licensed under the MIT License - see the LICENSE file for details.
FAQs
[](https://codecov.io/gh/jalez/react-shortcuts-provider) [](https://github.com/sponsors/jalez)
We found that @jalez/react-shortcuts-provider demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.

Security News
TeamPCP is partnering with ransomware group Vect to turn open source supply chain attacks on tools like Trivy and LiteLLM into large-scale ransomware operations.