homepage Welcome to WebmasterWorld Guest from 54.146.190.193
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Browsers / Opera Browser Usage and Support
Forum Library, Charter, Moderator: open

Opera Browser Usage and Support Forum

    
How to disable "keydown event" Opera browser for specific keystrokes ?
I want to write something else than the user type.Code not working in opera
seoul



 
Msg#: 4090195 posted 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.

 

seoul



 
Msg#: 4090195 posted 3:42 am on Mar 10, 2010 (gmt 0)

I've found my solution. I need to work on keypress event in opera.

Opera can't output the correct code in keypress event ( it gives 46 for both delete and dot button). But in keydown event it gives the correct code. So at first i detected if it were an opera browser, then i took the keycode from keydown event, saved in a variable and finally in keypress performed my tasks.

For other browsers the code will run normally in keydown event. Opera is an exception. You can find the code at: [code.google.com ]

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Browsers / Opera Browser Usage and Support
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved