Page is a not externally linkable
- Browsers
-- Opera Browser Usage and Support
---- How to disable "keydown event" Opera browser for specific keystrokes ?


seoul - 11:44 am on Mar 2, 2010 (gmt 0)


Hello, my program is a phonetic script for bangla language. It will act as follows: If a user type "k" in a textarea/text boxt then i'll output the corresponding unicode letter, for example 文 in the textarea/text (as if the user typed 文, not k). But i don't wanna do this for every keystroke, only a few.

Here is my selective code:

[b]HTML:[/b]
<textarea row="10" column="10" AUTOCOMPLETE="OFF" id="input_textbox01" onfocus="return passId(this);" value=''></textarea>

[b]Javascript:[/b]
function passId(oTextbox)
{
var inputbox=oTextbox;

inputbox.onkeydown= function (keyEvent)
{
oEvent= window.event || keyEvent;
oSource= oEvent.srcElement || oEvent.target;
//////////// should i deal this key press ?
iShouldDealIt=false;

var result=handleKeyboardInput(); // handleKeybaordInput function will change the value of iShouldDealIt if necessary

//alert(result);;
return result;
}

inputbox.onmousedown= function (keyEvent)
{
oEvent= window.event || keyEvent;
oSource= oEvent.srcElement || oEvent.target;
if( oEvent.button == 0)
{
updateRange(oEvent.rangeOffset); // update the mouse cursor position
}
return true;
}

inputbox.focus();
}

function handleKeyboardInput()
{
/*
-detect which key is pressed

If (the key belongs to the list that i wish to change) then
■ update source with the replacing value
■ return false so that browser doesn't write anything to the source text/textarea, i mean disable keydown event

else
return true; // Pressed key is not in my list, Let the browser normally in a keydown event.
*/

// skipped other or detail code

}


So if {k:1, a:5, m:8} is my selected list then for the input sequece: "s k d a p m" the output should be: "s 1 d 5 p 8"

Now, the code works fine with firefox 3.5, IE 6,7,8 and Chrome 0.4 to 3.

But in opera its not working. There it outputs: "s 1k d 5a p 8m"......Note that although k,a,m were typed but i retured false from handleKeyboard function so that onmousedown event return false, yet its not working.... Its working as if the event is not disabled so after my modification in the textbox it outputs the character also.

What should i do ? How can i disable keydown event for selective keystrokes ? Please help me.

Thanks.


Thread source:: http://www.webmasterworld.com/opera_browser/4090195.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com