|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
||||
|
||||
|
Equivlent to -window.event.keyCode- in other than IE browser
hello,
i have been wondering how i would use the window.event code in NN, FF, Opera, exc. does anyone know the equivlent? colton22 |
|
#2
|
|||
|
|||
|
Yes, but it's complicated, so I suggest you read at least some of these:
http://www.quirksmode.org/js/contents.html#events http://www.brainjar.com/dhtml/events/ http://www.w3.org/TR/DOM-Level-2-Events/events.html http://www.oreillynet.com/pub/a/jav...els.html?page=1 http://developer.apple.com/internet...ventmodels.html http://www.quirksmode.org/js/introevents.html http://www.javascriptkit.com/dhtmlt...eventp2-1.shtml Understanding IE's Event Model |
|
#3
|
|||
|
|||
|
You may also look for "Learn Javascript in 24 hours", it has several editions on the web but you have to often cut and paste it to a text file because the ads are badly placed and will not go away. They have an explaination of it in the Chapter Understanding Event Handlers (or something close to that depending on the edition) They also suggest skipping ahead in the book to the chapter on unobtusive scripting to help further with the concept. I am just now getting to that point in teaching myself so I can only refer my source, I hope it is helpful.
If you can't find it try under Sams Publishing you may find it there. I all else fails and you can't find it any other way send me a message and I will send you a way to get the info that I just don't want to broadcast to the world. |
|
#4
|
||||
|
||||
|
alright thanks, i will look it up
colton22 |
|
#5
|
||||
|
||||
|
I found the barrier breaker!!!!!
Code:
function handleKeyPress(evt) {
var nbr;
var nbr = (window.event)?event.keyCode:evt.which;
alert(nbr);
return true;
}
window.document.onkeydown= handleKeyPress;
From:http://saloon.javaranch.com/cgi-bin...c&f=20&t=004843 heck yea!!!! lol colton22 |
|
#6
|
|||
|
|||
|
Odd. The variable was declared twice.
keyCode is supported by more browsers than just IE/Win. I'd write it like this: Code:
function handleKeyPress(evt) {
evt = evt||window.event;
var nbr = (evt.keyCode)?evt.keyCode:evt.which;
alert(nbr);
return true;
}
|
|
#7
|
||||
|
||||
|
alright, now i am trying a random idea...
i need to check if the SHIFT modifier is down or not, or if caps lock is active, i found out in FF it doesnt matter if shift is down or not, it returns the code for the capitalized letters instead of lowercase, can anyone help on this one? colton22 |
|
#8
|
|||
|
|||
|
Perhaps this will help:
http://www.howtocreate.co.uk/jslibs...capsDetect.html |
|
#9
|
||||
|
||||
|
ummm... i really didnt understand much of that, is there any atribute to evt in the functions above to tell if it is down??
that is pretty confusing... colton22 |
|
#10
|
||||
|
||||
|
i got the shift down, not the caps lock though
colton22 |
|
#11
|
|||
|
|||
|
Quote:
No there isn't a property to check that. Hence why I didn't mention it and why he wrote that script. Yes, it's complicated. Why does that matter? |
|
#12
|
||||
|
||||
|
lol, im not sure why, it has been a question of mine for a while how to do, i guess im just trying to learn more about javascript and its capabilities.
lol colton22 |
![]() |
| Viewing: Dev Articles Community Forums > Programming > JavaScript Development > Equivlent to -window.event.keyCode- in other than IE browser |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|