Letters as Shortcut for Buttons

Use this board to ask questions or have discussions with other Rich Displays users.
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: Letters as Shortcut for Buttons

Post by Scott Klement »

I guess that depends on what 'event' is in your example...
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: Letters as Shortcut for Buttons

Post 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);
emhill
Experienced User
Posts: 116
Joined: Wed Sep 05, 2012 11:14 am
First Name: Eric
Last Name: Hill
Company Name: Integrated Corporate Solutions
Phone: 256-760-8239
Address 1: 501 S Wood Avenue
City: Florence
State / Province: Alabama
Zip / Postal Code: 35630
Country: United States
Contact:

Re: Letters as Shortcut for Buttons

Post by emhill »

Ha!! Thanks Scott! Imma gonna use that exact naming convention!!!!!!!
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests