Skip to content

Instantly share code, notes, and snippets.

@kawa-
Created September 7, 2016 05:29
Show Gist options
  • Save kawa-/d822ec363165e68c70a844ad50cb3a8e to your computer and use it in GitHub Desktop.
Save kawa-/d822ec363165e68c70a844ad50cb3a8e to your computer and use it in GitHub Desktop.
jQueryでshift + enter や ctrl + enter を使いたいとき (特に ctrl の場合は、以下のように keyCode 10 と 13 を指定する必要があり)
$("#form").on("keydown", function (e) {
if ((e.keyCode === 10 || e.keyCode === 13) && e.ctrlKey) {
console.log("enter + ctrl");
} else if (e.shiftKey && e.keyCode === 13) {
console.log("enter + shift");
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment