Created
February 5, 2020 14:31
-
-
Save sioniks/cf17ebef1440cdc4d08d953dd45ce958 to your computer and use it in GitHub Desktop.
report key event
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
function reportKeyEvent (zEvent) { | |
var keyStr = ["Control", "Shift", "Alt", "Meta"].includes(zEvent.key) ? "" : zEvent.key + " "; | |
var reportStr = | |
"The " + | |
( zEvent.ctrlKey ? "Control " : "" ) + | |
( zEvent.shiftKey ? "Shift " : "" ) + | |
( zEvent.altKey ? "Alt " : "" ) + | |
( zEvent.metaKey ? "Meta " : "" ) + | |
keyStr + "key was pressed." | |
; | |
$("#statusReport").text (reportStr); | |
//--- Was a Ctrl-Alt-E combo pressed? | |
if (zEvent.ctrlKey && zEvent.altKey && zEvent.key === "e") { // case sensitive | |
this.hitCnt = ( this.hitCnt || 0 ) + 1; | |
$("#statusReport").after ( | |
'<p>Bingo! cnt: ' + this.hitCnt + '</p>' | |
); | |
} | |
zEvent.stopPropagation (); | |
zEvent.preventDefault () | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment