Trigger onKeydown Without Activating Firefox Quick Search
Whilst working on ImpAmp, I was attempting to catch when the user typed ’ or / into the window without activating the firefox quick search. After hunting around on the web, I found lots of places telling me how to deactivate it permanently which is not what I want. Normally I find it very useful, just not when running ImpAmp. The solution that I found involved typing into a text-box. The quick search is disabled when typing in a form yet onkeydown still accepts the input. So I created a form at the bottom of my page:
:::html
I had tried to make the box hidden but then the box couldn’t gain focus and failed to work completely. Instead, I applied some css so the user wouldn’t notice it. This throws the form off the screen.
:::css #hiddenForm { position:absolute; left:-999px; top:-999px; }
So this method worked nicely until the input box loses focus. To ensure the box retains focus, add a function called by onkeyup which refocuses on the input box. I was also worried that the box might fill up, so I added another command that will empty the box.
:::js document.onkeyup = function keyPress(event) { document.getElementById(‘theBox’).focus(); document.getElementById(‘theBox’).value=‘’; }