Page 2 of 2

Re: Letters as Shortcut for Buttons

Posted: Mon Jun 06, 2016 8:06 am
by Scott Klement
I guess that depends on what 'event' is in your example...

Re: Letters as Shortcut for Buttons

Posted: Mon Jun 06, 2016 8:10 am
by Scott Klement
Actually, looking at my earlier example, it was not good because that event is calling an anonymous function, which would be difficult to unregister since it wasn't saved anywhere.

You'd have to do this in the onload event:

Code: Select all

window.ericsLovelyKeydownRoutine = function(event) {
    event = event || window.event;
    var key = event.which || event.keyCode;
   
    if(key == 89) {
      // 'Y' key pressed
      pui.click("btnYes");
    }
   
    if(key == 78) {
      // 'N' key pressed
      pui.click("btnNo");
    }   
   
}

addEvent(document, "keydown", window.ericsLovelyKeydownRoutine);
And this in the onsubmit:

Code: Select all

removeEvent(document, "keydown", window.ericsLovelyKeydownRoutine);

Re: Letters as Shortcut for Buttons

Posted: Mon Jun 06, 2016 9:10 am
by emhill
Ha!! Thanks Scott! Imma gonna use that exact naming convention!!!!!!!