@meadowsjared/qhotkeys
TypeScript icon, indicating that this package has built-in type declarations

1.1.15 • Public • Published

qHotkeys

Global shotcut replacement for Electron's implementation without preventing native OS shortcuts.

This project utilizes uiohook-napi. It depends on them and might not work on every system nor node/electron version.

My purpose in creating qHotkeys was to be a replacement for Electron's global shortcut. With qHotkeys you can create a shortcut such as CommandOrControl + X and your app will still recognize the input AND your os will perform the 'cut' action

This project is early in development. Report any bugs or issues on the GitHub issue tracker.

Installation

Install qHotkeys using npm:

npm i qhotkeys

Example Implementation

import { qKeys, qHotkeys } from 'qHotkeys'

// Create instance
var hotkeys = new qHotkeys()

// ... 
app.whenReady().then(() => {

    // ...

    // Your custom actions
    const hotkeyAction = () => {
        console.log("I pressed my hotkeys!")
    }

    const scrollUpAction = () => {
        console.log("I scrolled up!")
    }

    const scrollDownAction = () => {
        console.log("I scrolled down!")
    }

    // Registers your hotkey actions
    // Command or Control + X = hotkeyAction called
    hotkeys.register([qKeys.CmdOrCtrl, qKeys.X], hotkeyAction)
    
    // Registers your scroll actions
    // Command or Control + ScrollUp = scrollUpAction called
    // Command or Control + ScrollDown = scrollDownAction called
    hotkeys.registerScroll([qKeys.CmdOrCtrl], scrollUpAction, scrollDownAction)
    
    // For scroll register, the hotkey list can be empty
    hotkeys.registerScroll([], scrollUpAction, scrollDownAction)

    // Starts
    hotkeys.run()
    
    // ...
})

To-Do List

This project is early in development and I have lots of ideas to expand the capabilities. Here's a roadmap of planned additions to qHotkeys.

  • Add event info to the action callbacks
  • Individual scroll registers
  • Add mouse buttons
  • Add mouse move
  • Horizontal Scroll

Anymore ideas? Create an issue on the github page!

License

MIT

Maintained by QarthO.

Package Sidebar

Install

npm i @meadowsjared/qhotkeys

Weekly Downloads

0

Version

1.1.15

License

MIT

Unpacked Size

19.4 kB

Total Files

7

Last publish

Collaborators

  • meadowsjared