sciencefair-land / sciencefair

The futuristic, fabulous and free desktop app for working with scientific literature :microscope: :book:
https://sciencefair-app.com
MIT License
603 stars 52 forks source link

WIP: General solution for keybindings #130

Closed CAYdenberg closed 7 years ago

CAYdenberg commented 7 years ago

POC and solution to #68

Currently work in progress - do not merge

zeke commented 7 years ago

@CAYdenberg you probably don't want to use a globalShortcut here, as they detect keyboard events even when the application does not have keyboard focus.

Here's a guide that outlines various approaches for doing keyboard shortcuts in Electron: https://github.com/electron/electron/blob/master/docs/tutorial/keyboard-shortcuts.md

blahah commented 7 years ago

@zeke see #133 - was thinking of mousetrap for convenience. Do you know if it works reliably? Couldn't tell from electron docs if it used the electron APIs when available.

zeke commented 7 years ago

I've had great luck with mousetrap. It's just a browser lib and is entirely independent from Electron.

It should be noted however that it is specifically for handling events that occur within a browser window. In other words it can't handle keyboard events that occur when the window is not focused.

blahah commented 7 years ago

@zeke that sounds perfect - rn I don't think we need or want ScienceFair hijacking events when the app is not focused.

CAYdenberg commented 7 years ago

OK, I'll give that a try instead.

Out of curiousity @blahah why did the checks fail? I didn't see any test code in the project.

blahah commented 7 years ago

@CAYdenberg the tests are just to do with building and packaging apps and installers for different platforms when when cutting a release - you can safely ignore them.