Skip to content

Instantly share code, notes, and snippets.

@GoodBoyNinja
Last active November 17, 2023 22:27
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GoodBoyNinja/26e35f0c246dd694662964d503be1583 to your computer and use it in GitHub Desktop.
Save GoodBoyNinja/26e35f0c246dd694662964d503be1583 to your computer and use it in GitHub Desktop.
A small group of functions to let you intuitively check one of ctrl, shift or alt is pressed. Example: alert(pressed.shift())
var pressed = new (function () {
this.shift = function () {
if (ScriptUI.environment.keyboardState.shiftKey) {
return true;
}
return false;
};
this.alt = function () {
if (ScriptUI.environment.keyboardState.altKey) {
return true;
}
return false;
};
this.ctrl = function () {
if (ScriptUI.environment.keyboardState.ctrlKey) {
return true;
}
return false;
};
this.keyName = function (keyName) {
if (ScriptUI.environment.keyboardState.keyName(keyName)) {
return true;
}
return false;
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment