By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,843 Members | 2,311 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,843 IT Pros & Developers. It's quick & easy.

Any work-around? Opera 9 and keyCode

P: n/a
Hi,

I have function that works via onkeypressed -

for example, what to catch when a user presses a punctuation symbol
such as '.'

So I check keyCode for that - works just fine in
Opera 8, Mozilla/Firefox, IE

But in Opera 9 my code catches _both_ '.' and Delete button pressed -
both return 46 as a keyCode.
keyCode = evt.keyCode ? evt.keyCode :
evt.charCode ? evt.charCode :
evt.which ? evt.which : void 0;
CurrentKey = String.fromCharCode(keyCode) -

value is "." in _both_ cases.

In Opera 8, Mozilla/Firefox, IE the function working via
onkeypressed is NOT even called when I press Delete button...
I don't believe I am the first person to ran into this issue so
I hope some one has already figure out what to do -
don't let Opera 9 'think' that '.' was pressed when Delete button
was pressed.
--
Regards,
Paul Gorodyansky
http://RusWin.net
Sep 14 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
function that works via OnKeyDown showed more details -
unlike onkeypressed it _is_ called when Delete button is pressed.

So Opera 9 has a bug?

According to the value table for example here: http://tinyurl.com/pnjx4

keyCode value for Delete key is 46 while for a dot - '.' - value is 190

Firefox and IE show exactly that in the function called via onkeydown -
190 and 46

while Opera 9 shows 46 for _both_ Delete key abd '.'!

That is, it gives wrong value for '.'

Bug? Is it possible to find a work-around?

--
Regards,
Paul Gorodyansky
http://RusWin.net
Sep 14 '06 #2

P: n/a
Hi,

Found more details - looks like Opera 9 uses ASCII code and KeyCode
for Del and '.' in an opposite way to other browsers:

So does Opera 9 have a bug?

My function that works via OnKeyDown showed more details -

According to the value table for example here: http://tinyurl.com/pnjx4

- keyCode value for Delete key is 46
- while for a dot - '.' - value is 190

Firefox and IE show exactly that in the function called via onkeydown -
46 and 190

while Opera 9 shows 46 for _both_ Delete key abd '.'

That is, it gives wrong value for '.' - gives ASCII code instead
of keyCode (should be 190)
In the function that works via onkeypressed it's also wrong:

Here Opera 9 gives keyCode instead of ASCII code for Delete button:

for example, '[' - correct ASCII code 91
'.' - correct ASCII code 46

Del - incorrect - should be ASCII code 127 but instead it gives keyCode
= 46
Bug? Is it possible to find a work-around?
--
Regards,
Paul
Sep 14 '06 #3

P: n/a

So how to distinguish whether '.' was pressed or Delete in Opera 9?

Found more details - looks like Opera 9 uses ASCII code and KeyCode
for Del and '.' in an opposite way to other browsers:

So does Opera 9 have a bug?

My function that works via OnKeyDown showed more details -

According to the value table for example here: http://tinyurl.com/pnjx4

- keyCode value for Delete key is 46
- while for a dot - '.' - value is 190

Firefox and IE show exactly that in the function called via onkeydown -
46 and 190

while Opera 9 shows 46 for _both_ Delete key abd '.'

That is, it gives wrong value for '.' - gives ASCII code instead
of keyCode (should be 190)
In the function that works via onkeypressed it's also wrong:

Here Opera 9 gives keyCode instead of ASCII code for Delete button:

for example, '[' - correct ASCII code 91
'.' - correct ASCII code 46

Del - incorrect - should be ASCII code 127 but instead it gives keyCode
= 46
Bug? Is it possible to find a work-around?

--
Regards,
Paul
Sep 14 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.