1
0
mirror of https://github.com/taigrr/JSKeyCapture synced 2025-01-18 04:13:12 -08:00
JSKeyCapture/custom.js
Tai Groot c741723eac Update custom.js
Added examples for releaseKeys and releaseKey
2016-01-16 11:21:20 -08:00

25 lines
1.0 KiB
JavaScript

//Custom Ho
addShortcut(function(){
console.log("You pressed the keys Control, X, and Enter.");
},[key.CTRL,key.X,key.ENTER]);
addShortcut(function(){
console.log("You pressed 1, 2, and 4 at the same time.");
},[key.ONE, key.TWO, key.FOUR]);
//keep in mind that alert() blocks the keyup event, so if you have problems, include the followingin your code:
//to release all keys:
addShortcut(function(){
alert("You pressed the keys Control, Y, and Enter.");
releaseAllKeys();
},[key.CTRL,key.Y,key.ENTER]);
//This may not be desireable, as the user might still have keys pressed on the keyboard, and this would require the user to let up all keys.
//It might be better to only release one key, but check out how only releasing select keys might be problematic:
addShortcut(function(){
alert("You pressed the keys 1, 2, and 3.");
releaseKeys([key.ONE,key.TWO]);
// keyStrokes[key.THREE] = false;
},[key.ONE,key.TWO,key.THREE]);
//alternatively, usee releaseKey() to release only one key