@jojovms/ninja-keys-core
v0.0.1
Published
Commandō: Your commands, unleashed. A VS Code-style command palette for your web applications.
Maintainers
Readme
@jojovms/ninja-keys-core 🥷
A zero-dependency "Command Palette" interface (Ctrl+K) for Vanilla JS.
Installation
npm install @jojovms/ninja-keys-coreUsage
import { NinjaKeys } from '@jojovms/ninja-keys-core';
const ninja = new NinjaKeys({
actions: [
{ id: 'home', title: 'Go Home', icon: '🏠', handler: () => window.location = '/' },
{ id: 'theme', title: 'Toggle Dark Mode', icon: '🌙', handler: () => toggleMyTheme() }
],
hotkey: 'k' // Ctrl+K or Cmd+K
});
ninja.init();
// You can also open it manually via a button
document.getElementById('my-btn').onclick = () => ninja.toggle();Options
| Option | Type | Default | Description |
|---|---|---|---|
| actions | NinjaAction[] | [] | Array of actions (see below). |
| placeholder | string | 'Type a command...' | Search input placeholder. |
| theme | 'light' \| 'dark' | 'light' | Color theme. |
| hotkey | string | 'k' | Hotkey to toggle (combined with Ctrl/Cmd). |
Action Object
{
id: string;
title: string;
handler: () => void;
icon?: string; // Emoji or SVG
hotkey?: string; // Visual hint (e.g., 'ctrl+h')
section?: string; // (Future support) Grouping
keywords?: string; // Hidden search terms
}