473,320 Members | 1,867 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,320 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 18686
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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.