Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

onKeyPress select problem

Status
Not open for further replies.

kopite

Programmer
Apr 17, 2001
5
0
0
GB
Hi,

When the key press event has occured i want to capture the key pressed, so far I am having problems with this on the select tag.

This works
<Select Name=f1 onclick=&quot;ss();&quot; onKeyPress=&quot;alert('Hi');&quot;>

but this does not...
<Select Name=f1 onclick=&quot;ss();&quot; onKeyPress=&quot;nowt();&quot;>

<script language=javascript>
function nowt()
{
alert('Key pressed');
}
</script>

thanks for your help in advance,
 
one other thing I am doing this in IE 4 and above
 
This is the code I use to capture the alpha/numeric key pressed.

<script language=&quot;javascript&quot;>
function blah()
{
alert(String.fromCharCode(window.event.keyCode))
}
</script>

of course you still have to call it using the onkeypress.

Good luck
 
kopite,

The event handler that works with <select> is onChange.

Mike
 
Mr.Kopite ,
your code functions well in both forms,
and if you really are to catch the key pressed ,
the script from MrGPF (visitor) makes it clean.

 
Hi,

Thanks for that.

How can I pick up when the user has pressed the space bar?

thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top