Skip to content

Instantly share code, notes, and snippets.

@Phocacius
Created January 31, 2021 14:42
Show Gist options
  • Save Phocacius/660b48b4bcb816ad2dab60567757ed83 to your computer and use it in GitHub Desktop.
Save Phocacius/660b48b4bcb816ad2dab60567757ed83 to your computer and use it in GitHub Desktop.
var doAction = function() {
// do something when ctrl-enter is pressed
}
$(document).ready(function() {
var ctrlDown = false,
ctrlKey = 17,
cmdKey = 91,
enterKey = 13;
$(document).keydown(function(e) {
if (e.keyCode == ctrlKey || e.keyCode == cmdKey) ctrlDown = true;
}).keyup(function(e) {
if (e.keyCode == ctrlKey || e.keyCode == cmdKey) ctrlDown = false;
});
$(document).keydown(function(e) {
if (ctrlDown && e.keyCode == enterKey) doAction();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment