Reputation: 495
My friend challenged me to figure out a way to control YouTube (in Chrome) from the computer desktop (Or a program different from Chrome). Basically the idea here is to fire an event where I can handle what to do with certain hotkey combos. Chrome has an api (chrome.commands
) that allows for this, but the user must be in chrome for it to fire the event (which makes sense). I would like to discuss any possible alternatives.
I know extensions can have file access to the computer (using chrome.fileSystem
api), so I was thinking of having a folder somewhere that had text file(s) that would be written to by a script running on the user's computer. The script could also potentially just be a macro fired by Windows on a certain key stroke.
Is this a practical approach, or are there easier ways to accomplish this? It just seems like there's a lot of "moving" parts needed to make this work.
EDIT: Main goal here is to get skip and pause/play keys (that some keyboards have) to work with chrome. using Ctrl+Shift+[0-9] works with chrome.commands
, but anyone have other suggestions to get those other keys to work?
Upvotes: 0
Views: 663
Reputation: 77523
chrome.commands
has a very limited set of shortcuts that work globally:
By default, Commands are scoped to the Chrome browser, which means that while the browser does not have focus, the shortcut will be inactive. On desktop Chrome, Commands can instead have global scope, as of version 35, and will then also work while Chrome does not have focus. NOTE: The exception here is Chrome OS, where global commands are not allowed at the moment.
The user is free to designate any shortcut as global using the UI in chrome://extensions \ Keyboard Shortcuts, but the extension developer is limited to specifying only Ctrl+Shift+[0..9] as global shortcuts. This is to minimize the risk of overriding shortcuts in other applications since if, for example, Alt+P were to be allowed as global, the printing shortcut might not work in other applications.
Documentation is available here.
Upvotes: 1