Using jQuery this works fine:
$(document).on('click','a.clickmap',function(e){ alert('h'); }
However I want to do something when a key is pressed. I've tried both of these:
$(document).on('keypress','body', function(e){
if(e.which==78) {
alert('n');
// "n"
}
$(document).on('keypress', function(e){ //ditto };
Neither works!
I just tried this code in HTML Service, and it worked:
That code works for keypresses in the input box, not anywhere in the body, but I changed:
to:
and put some
<body></body>tags in my HTML and it worked. The Google documentation does suggest to not use<body>tags.Google Documentation Link
I'd copy the basic structure of this code that works, get something to work, and then go from there.