onkeypress event: ' and / characters

C

cloudguitar

Hello all!

In some engines like Gecko(Firefox) and KHTML(Konqueror), pressing the
' or / key
turns the "quick find" mode on in the browser, moving the focus away
from the current element.

I have a webpage with document.onkeypress set to a callback function,
and I'd like to
be able to work with all the key events without losing the focus. Is
there any workaround that
would me let disable that "quick find" mode from JS or, anyway, avoid
losing the focus?

Thank you very much,

Claudio A.
 
J

Joost Diepenmaat

cloudguitar said:
I have a webpage with document.onkeypress set to a callback function,
and I'd like to
be able to work with all the key events without losing the focus. Is
there any workaround that
would me let disable that "quick find" mode from JS or, anyway, avoid
losing the focus?

return false; from the handler will block more or less any key action.

Joost.
 
S

SAM

cloudguitar a écrit :
Hello all!

In some engines like Gecko(Firefox) and KHTML(Konqueror), pressing the
' or / key
turns the "quick find" mode on in the browser, moving the focus away
from the current element.

that doesn't append when you type in a text-field
I have a webpage with document.onkeypress set to a callback function,

and of corse you absolutly need to use these 2 keys ? !
 
C

cloudguitar

I think I found a decent solution, even if it's a trick and not a
"canonical" one.

I put a <input id="in" style="width:0; height:0" readonly></input>
inside the page.
Then, I use its onkeypress to retrieve the keys, and that does work
very well, as
no browser-specific shortcut is active on INPUT fields.
Again, to avoid losing the focus from the INPUT, I put a handler to
document.getElementById("in").onblur and to document.onfocus that sets
the focus back
to the INPUT field. It seems to work even on Explorer 6.

I needed those two uncommon keys because I listen to _code_ input, and
it would be a
significant reduction not to include them.

Thanks for your suggestions

Claudio A.
 
C

cloudguitar

I think I found a decent solution, even if it's a trick and not a
"canonical" one.

I put a <input id="in" style="width:0; height:0" readonly></input>
inside the page.
Then, I use its onkeypress to retrieve the keys, and that does work
very well, as
no browser-specific shortcut is active on INPUT fields.
Again, to avoid losing the focus from the INPUT, I put a handler to
document.getElementById("in").onblur and to document.onfocus that sets
the focus back
to the INPUT field. It seems to work even on Explorer 6.

I needed those two uncommon keys because I listen to _code_ input, and
it would be a
significant reduction not to include them.

Thanks for your suggestions

Claudio A.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top