Last active
August 29, 2015 13:57
-
-
Save twolfson/9480774 to your computer and use it in GitHub Desktop.
Proof of concept for media keys in node-webkit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Media key press test</title> | |
</head> | |
<body> | |
<h1>Key pressed</h1> | |
<p id="output">null</p> | |
<script> | |
(function () { | |
// Load in dependencies | |
var gui = require('nw.gui'); | |
// Grab the output element | |
var $output = document.getElementById('output'); | |
console.log('wat'); | |
// Define a shortcut | |
// https://github.com/rogerwang/node-webkit/pull/1735/files#diff-2c0e331a5f16a997364d359a556b5acdR36 | |
// https://github.com/rogerwang/node-webkit/pull/1735/files#diff-a392d93e2592c5b8119a1fba725e9f5aR10 | |
var shortcut = new gui.Shortcut({ | |
key: 'Alt+Shift+X', | |
active: function () { | |
$output.textContent = 'Shortcut activated'; | |
}, | |
failed: function () { | |
$output.textContent = 'Failed to bind shortcut'; | |
} | |
}); | |
gui.App.registerGlobalHotKey(shortcut); | |
}()); | |
</script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "gist-node-webkit-media-keys", | |
"main": "index.html" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment