473,395 Members | 1,535 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Modifying a onkeyup event to ignore Tab keypress

Is there anyway to tweak this to ignore the function() only if the Tab
key is pressed?
onkeydown="javascript:function();"
Jul 20 '05 #1
5 18696
ma******@yahoo.com (Matthew) writes:
Is there anyway to tweak this to ignore the function() only if the Tab
key is pressed? onkeydown="javascript:function();"


"function" is a keyword, so it is a bad example to use.
The "javascript:" is not needed.

onkeydown="if ((event.keyCode||event.which) != 9){ func(); }"

The event.which is meant for Netscape 4, but a little wasted on this
example, since it won't catch the tab key anyway.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2
Lasse Reichstein Nielsen wrote on 08 feb 2004 in comp.lang.javascript:
ma******@yahoo.com (Matthew) writes:
Is there anyway to tweak this to ignore the function() only if the Tab
key is pressed?
onkeydown="javascript:function();"


"function" is a keyword, so it is a bad example to use.
The "javascript:" is not needed.

onkeydown="if ((event.keyCode||event.which) != 9){ func(); }"


Isn't it this what the OP wants:

<input
onkeydown="return (event.keyCode||event.which) != 9;"


--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 20 '05 #3
> Isn't it this what the OP wants:

<input onkeydown="return (event.keyCode||event.which) != 9;">

I am confused with this, basically I want whatever(); to execute
somewhere in there... I couldn't get the other posters version to work
and I don't see how to call my function with this. Any ideas?
Jul 20 '05 #4
Ok, slight update here... I stand corrected, the other posters version
works, except when I implement it on a onkeyup instead of onkeydown,
it oddly ignores the call...
onkeyup="if ((event.keyCode||event.which) != 9){ something(); }"
onkeydown="if ((event.keyCode||event.which) != 9){ something(); }"

Separately, what is the keyevent # for a SHIFT-TAB?
Jul 20 '05 #5
ma******@yahoo.com (Matthew) writes:
Separately, what is the keyevent # for a SHIFT-TAB?


The keyCode is still 9 (in the browsers I have tested), but the
event's shiftKey property will be true as well. However, just pressing
the shift key alone will trigger the keydown with keyCode 16, which
you might want to avoid too.

onkeydown="if (!(event.keyCode==9 && event.shiftKey)){something();}"

should call something except when you press shift-Tab. Including when
you press shift.

onkeydown="if (!(event.keyCode==16 || (event.keyCode==9 && event.shiftKey)))
{something();}"

This should omit the shift as well.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Trent | last post by:
Hi. I know the basic way to assign event handlers: <input onKeyUp="processEvent(event)" /> But how do I assign a function to the onKeyUp event in *javascript* that can access the event...
2
by: Evan Wong | last post by:
I have problem to get onkeyup event. If we put the event in HTML statement like - "<input name=field1 size=16 onkeyup="javascript:function1();>" it works. If we put in JavaScript code like...
2
by: john.lum | last post by:
My overall objective is to create something akin to Google Suggest, where a query is done in response to changes in a text field presented to the user. I've got things working using the onkeyup...
3
by: Brad | last post by:
The first text on my form is a numeric field. I have a javascript that runs on this field for onkeyup (validate the key strokes and modifies fields on the screen) but when I do this and have the...
1
by: manojsharma | last post by:
hey can anybody tell me y my onkeyup event is not working in firefox.. it is working fine in IE... code <input type="text" name="oddteam" size="1" value="1" ...
3
by: Brent | last post by:
The code below correctly sets an iframe to be editable, and then tries to attach an "onkeyup" event to the iframe. Instead of doing that, however, it generates a cryptic "Object required" error in...
0
by: user1980 | last post by:
How do I write a custom validator for the onkeyup event. my scenario is two textboxes and if one of them is filled the other has to be filled to. if not both need not be filled(so, onkeyup event...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.