electron-hotkey-menu
TypeScript icon, indicating that this package has built-in type declarations

1.1.2 • Public • Published

Welcome to electron-hotkey-menu 👋

Version Documentation Maintenance License: MIT

Does your Electron app use hotkeys? Do you want your users to configure these hotkeys themselves? This package will create a customisable key-binding menu for you, with simple, non-boilerplate code.

🏠 Homepage

Install

npm install electron-hotkey-menu

Usage

import {HotkeyMenu, Hotkey} from "electron-hotkey-menu"
 
 
const hotkeys : HotkeyMenu = new HotkeyMenu({
    // Width and height of menu
    width:400,
    height:400,
 
    // Custom CSS
    css:'./custom-menu.css',
 
    // Custom savefile. Use this if you want separate hotkey menus. Defaults to hotkeys.json
    savefile:"custom-hotkey-file.json",
 
    // Add hotkeys directly
    hotkeys:
        [
            // Label, default shortcut, function to execute
            new Hotkey("Hotkey 1", "Alt+O", () => {
                console.log("Hotkey activated")
            }),
            new Hotkey("Hotkey 2", "", functionName)
        ]
})
 
 
// Hotkey added later
hotkeys.addHotkey(new Hotkey("Hotkey 3", "Shift+c", () => {
    console.log("Later added hotkey activated")
}))
 
// Register hotkeys before showing menu
hotkeys.registerHotkeysGlobal()
 
// Load menu on a button press
document.getElementById("hotkeys").onclick = () => hotkeys.displayMenu()

alt text

Hotkeys are saved between program launches and stored in hotkeys.json where the application was launched.

Author

👤 Jakob Hansen

🤝 Contributing

Contributions, issues and feature requests are welcome!
Feel free to check issues page. You can also take a look at the contributing guide.

Show your support

Give a ⭐️ if this project helped you!

📝 License

Copyright © 2020 Jakob Hansen.
This project is MIT licensed.


This README was generated with ❤️ by readme-md-generator

Package Sidebar

Install

npm i electron-hotkey-menu

Weekly Downloads

9

Version

1.1.2

License

MIT

Unpacked Size

26.7 kB

Total Files

11

Last publish

Collaborators

  • jakobkhansen