Networking | Hardware | Software | Multimedia | System | Unix&Linux | MBA

Home>>Hardware>>Changing e.keyCode (e.which)

Changing e.keyCode (e.which)

orhor
02-04-2005, 12:12 AM
hi all,

when key pressed, in IE i can use this code:

event.keyCode=somenumber;

and it works. Is this possible in Netscape - Firefox - ..... ?

I need to controll the input, I want to allow users to use only keys I want them to use.

Thanks

meena
02-04-2005, 07:09 AM
There is slight variation in the way IE and Netscape behaves for Event Handlers.


function doSomething(e)
{
var code;
if (!e) var e = window.event;
if (e.keyCode) code = e.keyCode;
else if (e.which) code = e.which;
var character = String.fromCharCode(code);
alert('Character was ' + character);
}

orhor
02-04-2005, 11:34 AM
im afraid you didnt understand me. when the cursor is in a textbox and user presses a key 'A' in IE and I use this: event.keyCode=124 - pipe (|) will be displayed. IE will behave like pipe was pressed. Not 'A'.
But when I try to set some value into e.keyCode or e.which I get an error: object has only a getter. Any way out?
(My english isnt very well but I think it means this object is read only, isnt it)


 

TOP

For more info

setting a minimum size
Auto Preview of Image 
Refresh with a query s
JS Validation obsolete
Javascript Pop up func
Slide show transitions
I'm a newbie...please!
how to write coding in
Advanced Debug Info 
.js file doesn't work 

News Archive

Adding Graphic To Text
re-direct form after s
pop up window controls
Clock on homepage - He
passing a param from a
Password Procection wi
document.title in same
focus onload 
Counting Wrong from Ri
Help needed on how to 

Related stories:

write to an html file dynamically?
FireFox doesn't recognize history.go(-1)
Clearing a range created by element.createTextRange()
UPDATE: My mouse over pop up question
I am having problem with this script!!!
Creating Handlers
"Login ID" pass over to subsequent pages visited
Checkbox to manipulate Form Field

Copyright@2004-2005 www.zzcoke.com All Right Reserved

advanced web statistics