Created
January 31, 2021 14:42
-
-
Save Phocacius/660b48b4bcb816ad2dab60567757ed83 to your computer and use it in GitHub Desktop.
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
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