Keyboard shortcuts interface for your website. Work with vanilla JS, Vue, and React.
keyboard shortcuts ux, keyboard shortcuts best practices, uipath keyboard shortcuts activity, uipath keyboard input, keyboard ui, uipath comment out shortcut
Why the name “Ninja”?
Because it appears out of nowhere and performs any actions quickly. Or it allows users to become a keyboard ninja đ
Features
- Navigating with the keyboard
- Light and dark theme built-in
- Supported embedded icons from the physical font can support custom SVG icons too.
- Nested menu can use either a tree or flat data structure
- Automatic register of your shortcuts
- Root search, for example, if you search for “Dark” you will find it in the “Theme” submenu
- CSS variable to customize the display
- Customizable hotkeys for opening/closing etc. Choose what fits your website the most.
How to make use of it:
1. Install and import ninja keys.
# NPM $ npm i ninja-keys
import 'ninja-keys';
// or <script type="module" src="https://unpkg.com/ninja-keys?module"></script>
2. Add the custom <ninja-keys> element to the page.
<ninja-keys placeholder="Custom Placeholder"></ninja-keys>
3. Define your own hotkeys.
const hotkeys = [ { id: "myHotkey-1", title: "Hot Key 01", hotkey: "cmd+h", icon: "custom icon html here", mdIcon: "home", // Material Icon keywords: "home", // keyword handler: () => { console.log("navigation to home"); } }, { id: "Theme", title: "Change theme...", mdIcon: "desktop_windows", children: [ { id: "Light Theme", title: "Change theme to Light", mdIcon: "light_mode", handler: () => { console.log("theme light"); } }, { id: "Dark Theme", title: "Change theme to Dark", mdIcon: "dark_mode", keywords: "lol", handler: () => { console.log("theme dark"); } } ] } ];
4. Configure the search UI cmd + k.
const ninja = document.querySelector("ninja-keys"); ninja.data = hotkeys;
5. Open the interface manually.
ninja.open(); // or ninja.open({ parent: 'Theme' })
6. Change the theme to “Dark”.
<ninja-keys class="dark"></ninja-keys>
7. Add a footer to the interface.
<ninja-keys> <slot name="footer">Must custom footer</slot> </ninja-keys>
Attributes
Field | Default | Description |
---|---|---|
placeholder | Type a command or search… | Placeholder for search |
disableHotkeys | false | If attribute exist will register all hotkey for all actions |
hideBreadcrumbs | false | Hide breadcrumbs on header if true |
openHotkey | cmd+k,ctrl+k | Open or close shortcut |
navigationUpHotkey | up,shift+tab | Navigation up shortcuts |
navigationDownHotkey | down,tab | Navigation down shortcuts |
closeHotkey | esc | Close shotcut |
goBackHotkey | backspace | Go back on one level if has parent menu |
selectHotkey | enter | Select action and execute handler or open submenu |
hotKeysJoinedView | false | If exist/true will display hotkeys inside one element |
noAutoLoadMdIcons | false | If exist it disable load material icons font on connect |
Data
Array of INinjaAction
 – interface properties below
Name | Type | Description |
---|---|---|
id | string | Unique id/text. Will be displayed as breadcrumb in multimenu |
title | string | Title of action |
hotkey | string(optional) | Shortcut to display and register |
handler | Function(optional) | Function to execute on select |
mdIcon | string(optional) | Material Design font icon name |
icon | string(optional) | Html to render as custom icon |
parent | string(optional) | If using flat structure use id of actions to make a multilevel menu |
keywords | string(optional) | Keywords to use for search |
children | Array(optional) | If using flat structure then ids of child menu actions. Not requried on tree structure |
section | string(optional) | Section text. Like a header will be group with other same sections |
Methods
Name | Arg | Description |
---|---|---|
open | { parent?: string } | Open menu with parent, if null them open root menu |
close | Â | Close menu |
setParent | parent?: string | Navigate to parent menu |
CSS variables
Name | Default |
---|---|
–ninja-width | 640px; |
–ninja-backdrop-filter | none; |
–ninja-overflow-background | rgba(255, 255, 255, 0.5); |
–ninja-text-color | rgb(60, 65, 73); |
–ninja-font-size | 16px; |
–ninja-top | 20%; |
–ninja-key-border-radius | 0.25em |
–ninja-accent-color | rgb(110, 94, 210); |
–ninja-secondary-background-color | rgb(239, 241, 244); |
–ninja-secondary-text-color | rgb(107, 111, 118); |
–ninja-selected-background | rgb(248, 249, 251); |
–ninja-icon-color | var(–ninja-secondary-text-color); |
–ninja-icon-size | 1.2em; |
–ninja-separate-border | 1px solid var(–ninja-secondary-background-color); |
–ninja-modal-background | #fff; |
–ninja-modal-shadow | rgb(0 0 0 / 50%) 0px 16px 70px; |
–ninja-actions-height | 300px; |
–ninja-group-text-color | rgb(144, 149, 157); |
–ninja-footer-background | rgba(242, 242, 242, 0.4); |
Keyboard Shortcuts UI (cmd+k) For The Web, Ninja Keys Plugin/Github, keyboard shortcut design, ui copywriting
See Demo And Download
Official Website(ssleptsov): Click Here
This superior jQuery/javascript plugin is developed by ssleptsov. For extra Advanced usage, please go to the official website.