![Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility](https://cdn.sanity.io/images/cgdhsj6q/production/97774ea8c88cc8f4bed2766c31994ebc38116948-1664x1366.png?w=400&fit=max&auto=format)
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Simple package to manage keyboard shortcuts
npm i keyshort
yarn add keyshort
pnpm add keyshort
You can take a look at the example
import {KeyShortProvider} from 'keyshort';
const App = () => {
return (
<KeyShortProvider>
hello world
</KeyShortProvider>
);
};
It is recommended that you place the provider at the beginning of the component tree.
You can register commands globally
import {KeyShortProvider, ShortcutType} from 'keyshort';
const GLOBAL_COMMANDS: ShortcutType[] = [
{
keys: {
Mac: ['Meta', 'Shift', 'P'],
Windows: ['Control', 'Shift', 'P'],
},
label: 'Test command',
callback: () => {
alert('Hello world');
},
},
];
const App = () => {
return (
<KeyShortProvider shortcuts={GLOBAL_COMMANDS}>
hello world
</KeyShortProvider>
);
};
You can register a command in a specific part of your application. This is useful when we want to execute logic from a handler that exists in a specific component.
import {KeyShortProvider, useKeyShort} from 'keyshort';
const RegisterShortcutButton = () => {
const {registerShortcut} = useKeyShort();
const handleClickRegister = () => {
registerShortcut({
keys: {
Mac: ['Shift', '*', '_'],
},
label: 'This is a keyboard shortcut',
callback: () => {
alert('Hello world');
},
});
};
return (
<div>
<button onClick={handleClickRegister}>Register shortcut</button>
</div>
);
};
const App = () => {
return (
<KeyShortProvider>
<RegisterShortcutButton/>
</KeyShortProvider>
);
};
You can list the registered shortcuts using the useKeyShort hook
import {KeyShortProvider, useKeyShort} from 'keyshort';
const ShowShortcuts = () => {
const {shortcuts} = useKeyShort();
const shortcutsList = shortcuts?.map((shortcut, index) => {
return (
<div key={index}>
<span>{shortcut.label}</span>
<ul>
{Object.entries(shortcut.keys).map(([key, values], i) => (
<li key={`${key}-${i}`}>
{key}: <strong>{values.join(' + ')}</strong>
</li>
))}
</ul>
</div>
);
});
return (
<div>
<h1>Registered Shortcuts</h1>
{shortcutsList}
</div>
);
};
const App = () => {
return (
<KeyShortProvider>
<ShowShortcuts/>
</KeyShortProvider>
);
};
FAQs
Simple package to manage keyboard shortcuts
The npm package keyshort receives a total of 0 weekly downloads. As such, keyshort popularity was classified as not popular.
We found that keyshort demonstrated a not healthy version release cadence and project activity because the last version was released 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.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.