Hi HJ, Thanks for the reply. I wanted to use keypress so I didn't have to manage the up/down state of the key (I would bet there are alternative input devices which allow you to keydown in one window but release the key--keyup--in another window). That said, I'll give it a try with keyup. To hell with those alternative input devices :)
----- Original Message ---- From: HJ van Rantwijk <[EMAIL PROTECTED]> To: [email protected] Sent: Monday, September 25, 2006 7:16:29 PM Subject: Re: [Project_owners] capturing keypress and handing to default listener -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Eric H. Jung wrote: > Hi, > > I capture keypress events in a dialog. If the keypress is a number, my > listener performs an action. If it's not a number, I want the default > keypress event listener to process the event. No matter what I've tried, I > can't get the default event listener to process the event once my listener > has the keypress. I use onkeydown and onkeyup and that works for me in five managers. window.document.addEventListener("keydown", keydownHandler, false); window.document.addEventListener("keyup", keyupHandler, false); keyupHandler(aEvent) { if (aEvent.keyCode == aEvent.DOM_VK_ESCAPE) callFunction(); } > I've tried window.addEventListener("myListener", onKeyPress, false), > window.addEventListener("myListener", onKeyPress, true) where myListener is: > > function myListener(evt) { > if (!isNaN(evt.charCode)) { // if user typed a number, select the > corresponding tree row > var row = parseInt(evt.charCode-KeyboardEvent.DOM_VK_0)-1; > row <= accountsTree.view.rowCount-1 && > accountsTree.view.selection.select(row); > // Shouldn't other event listeners now be called? > } > > I've also tried the non-DOMEvent way: > > var origOnKeyPress; > function onLoad() { > origOnKeyPress = window.keypress; > window.onKeyPress = myListener; > } > > function myListener(evt) { > if (!isNaN(evt.charCode)) { // if user typed a number, select the > corresponding tree row > var row = parseInt(evt.charCode-KeyboardEvent.DOM_VK_0)-1; > if (row <= accountsTree.view.rowCount-1) > accountsTree.view.selection.select(row); > else > origOnKeyPress(evt); > } > else > origOnKeyPress(evt); > } > > Thanks for any ideas, > Eric > > -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (MingW32) iD8DBQFFGGNNRrb6S73JMeYRApUSAJ0WxutZ3qtI1qYYX/b45Lsob/ugMQCgyAf6 Gizbsy7we6ps54sCf/KLiJg= =sbyW -----END PGP SIGNATURE----- _______________________________________________ Project_owners mailing list [email protected] http://mozdev.org/mailman/listinfo/project_owners _______________________________________________ Project_owners mailing list [email protected] http://mozdev.org/mailman/listinfo/project_owners
