onkeypress event problem

W

Wescotte

I have several <input type = 'text' ....> where I would like to allow
certain hotkeys to auto fill the data.

ie shift + 1, shitf + 2 etc etc

so I have

<input type = 'text' name = 'test_input' onkeypress =
'Check_Keys(this);'>

function Check_Keys(id)
{
if (window.event.shiftKey)
switch (window.event.keyCode) {
case 33: // Shift + 1
id.value = "You hit Shift + 1";
return false;
break;
}
return true;
}

Now if I hit shift +1 it fills the input with You hit Shift +1 but it
also appends a "!"

How can I tell it not to append the last keystroke?
 
W

Wescotte

I was able to get it to not append the keystroke however now I want to
force an onChange event to occur. How can I go about doing this?
 
M

MB

Wescotte said:
I was able to get it to not append the keystroke however now I want to
force an onChange event to occur. How can I go about doing this?

In the Check_Keys function:

id.fireEvent("onchange");
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,222
Members
46,810
Latest member
Kassie0918

Latest Threads

Top