faqts : Computers : Programming : Languages : JavaScript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

110 of 145 people (76%) answered Yes
Recently 8 of 10 people (80%) answered Yes

Entry

event.which == 13 is not the enterkey for NS 6 like event.keyCode == 13 for IE enterkey, What is the real code to find out enterkey pressed on NS6

Apr 4th, 2008 20:41
ha mo, Ian Grant, Lutfoun khanam,


Just like you would in IE!  Here is a list of NN6's Event Object 
Properties (in alphabetical order) with a brief description of each:
Property       Value    Description
--------       -----    -----------
altKey         boolean  (true == pressed)
bubbles        boolean  (true == event bubbles, false == event doesn't)
button         string   (1 == left, 3 == right)
cancelable     boolean  (true == event can be cancelled)
cancelBubble   boolean  (true == event bubbling is/becomes cancelled)
ctrlKey        boolean  (true == pressed)
currentTarget  boolean  (object where listener intercepted event)
eventPhase     long     (0 == capture, 1 == found target, 3 == bubbling)
keyCode        long     (ASCII keycode)
shiftKey       boolean  (true == pressed)
target         object   (where event will turn and bubble upward)
type           string   (event name "click", "mouseover", etc.)
Try this code snippet in NN6:
<script language="javascript">
<!--
function readKey(e) {
        window.status = e.keyCode;
}
document.onkeypress = readKey;
// -->
</script>
As in NN4, when the event is captured it is passed to the function as 
the first argument.  You cannot simply use event.keyCode like in IE.
I hope this helps.
Ian Grant
[email protected]
http://www.businessian.com
http://www.computerstan.com
http://www.financestan.com
http://www.healthstan.com
http://www.internetstan.com
http://www.moneyenews.com
http://www.technologystan.com
http://www.zobab.com
http://www.healthinhealth.com