Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved Global Keyboard Shortcut listeners #93

Closed
5 tasks done
sancarn opened this issue Mar 21, 2021 · 1 comment · Fixed by #124
Closed
5 tasks done

Improved Global Keyboard Shortcut listeners #93

sancarn opened this issue Mar 21, 2021 · 1 comment · Fixed by #124
Labels
enhancement New feature or request
Projects

Comments

@sancarn
Copy link
Contributor

sancarn commented Mar 21, 2021

Improved listeners using IOHook so can listen to meta key and others.

  • Create and implement global key listeners in node-global-key-listener. Progress see here
  • Implement a wrapper in LM around node-global-key-listener.
  • Create a settings type for global listeners
    • Make the settings store the keycodes, and display character names obtained from the browser
    • Add a function to this setting type to register a listener for it
@sancarn sancarn added the enhancement New feature or request label Mar 21, 2021
@sancarn sancarn added this to To do in LaunchMenu Mar 21, 2021
@sancarn
Copy link
Contributor Author

sancarn commented Mar 30, 2021

Currently we have an issue installing global hotkeys in LaunchMenu.

Option 1: Do nothing

Currently we used Electron's global hotkey libraries but these are very limited as they use more restricted hotkey binding systems.

Option 2: Use IOHook

Problems: IOHook only supports a set of node and electron versions. Building is a bit of a nightmare.

Option 3: Use native implementation

Windows implementation

This implementation is described here. I've included some pseudocode below.

const WH_GETMESSAGE = 3
function Register(){
   this.hook = SetWindowHookEx(WH_GETMESSAGE, pointerTo(MyMsgProc), 0, 0)
}
function Unregister(){
  if(!UnhookWindowsHookEx(this.hook)){
    throw "Cannot unhook"
  }
}
function MyMsgProc(code, wParam, lParam){
  if(code == WM_KEYDOWN){
    //Detect keycode in wParam
    
    //Propogation
    if(!stopPropogation){
      CallNextHookEx(this.hook, code, wParam, lParam)
    }
  } else {
    CallNextHookEx(this.hook, code, wParam, lParam)
  }
}

Mac implementation

The following is the implementation for Macs written in swift.

see implementation of an event-tap in mac os here

Option 4: Use Node FFI

The above could be implemented in Node-FFI. This could mean that we have a bit of a build nightmare though...

Windows Implementation

@TarVK TarVK moved this from To do to In progress in LaunchMenu Apr 6, 2021
@TarVK TarVK linked a pull request May 28, 2021 that will close this issue
@TarVK TarVK moved this from In progress to Done in LaunchMenu Jun 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
LaunchMenu
  
Done
Development

Successfully merging a pull request may close this issue.

1 participant