473,395 Members | 2,006 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.

javascript/ change enter key to tab keypress

this work great and stops all enter key presses. now how do i disable the event and fire a tab key event.
so if a user presses the enter key i need it to be ignore and tab to the next field.

<head>
<script type="text/javascript">

function kH(e) {
<!--
var pK = document.all? window.event.keyCode:e.which;
return pK != 13;
}

document.onkeypress = kH;
if (document.layers) document.captureEvents(Event.KEYPRESS);
file://-->
</script>
</HEAD>
Apr 27 '06 #1
8 109625
here is code that works! must be in body tag.
<body> onkeydown="if (event.keyCode==13) {event.keyCode=9; return event.keyCode }"
Apr 27 '06 #2
here is code that works! must be in body tag.
<body> onkeydown="if (event.keyCode==13) {event.keyCode=9; return event.keyCode }"
The above code was a lot help. But in my web page I have to also access the links using keyboard. In that case I have to use the alt + access key and then press enter to access a particular link. So if I use the above code then I am not able to access the links using keyboard.
Jun 1 '06 #3
This Code is Working Fine with all controls , means the Focus is moving to Next Control. BUT this is not working When the Focus is in "HtmlInput File"Control which we will use for File UpLoadings. means Focus is not moving to Next Control. Then How to modify code.


this work great and stops all enter key presses. now how do i disable the event and fire a tab key event.
so if a user presses the enter key i need it to be ignore and tab to the next field.

<head>
<script type="text/javascript">

function kH(e) {
<!--
var pK = document.all? window.event.keyCode:e.which;
return pK != 13;
}

document.onkeypress = kH;
if (document.layers) document.captureEvents(Event.KEYPRESS);
file://-->
</script>
</HEAD>
Feb 15 '07 #4
asipo
1
actually the code provide by rrosebro is not working for me =.=

and i try alot with that kind of coding where u try to set the 13 into 9

and i think the web browser ( im using mozilla firefox 2.0.0.14 ) not allowing us to change that

so heres my code to solve the enter as tab ( using an id as element )


at the script part
Expand|Select|Wrap|Line Numbers
  1.        function testing(event,number)
  2.     {
  3.         if( event.keyCode == 13 )
  4.         {
  5.             var wow = document.getElementById(number);
  6.             wow.focus();
  7.         }        
  8.     }

so the input will look like this
Expand|Select|Wrap|Line Numbers
  1. <form>
  2.           <input id="1" type="text" tabindex="1" onkeyup="testing(event,2)" />
  3.           <input id="2" type="text" tabindex="3" onkeyup="testing(event,3)" />
  4.           <input id="3" type="text" tabindex="2" onkeyup="testing(event,1)" />
  5. </form>
Jun 26 '08 #5
acoder
16,027 Expert Mod 8TB
Welcome to Bytes and thanks for sharing.

Remember that IDs should not start with or be only numbers, so use a string not starting with a number.
Jun 26 '08 #6
its too simple dear,
in body tag just add this
<body onkeydown="if (event.keyCode==13) {event.keyCode=9; return event.keyCode }">

DONE!.. :) Now your ENTER key will be treated as TAB key to focus other controls..

Regards
Sheryar Nizar
[url removed]
Jul 17 '08 #7
acoder
16,027 Expert Mod 8TB
Are you sure about that? Have you tested on browsers besides IE? What about textareas?

I've removed the link in your post. Please read the Posting Guidelines.
Jul 17 '08 #8
Logician
210 100+
this work great and stops all enter key presses. now how do i disable the event and fire a tab key event.
so if a user presses the enter key i need it to be ignore and tab to the next field.
Try using EnterToTab
Jul 17 '08 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: deko | last post by:
I have a textbox in a form into which users enter a string to execute a search. After the user presses Enter, I'd like the focus to go back to the textbox, but the default behavior of the Enter...
3
by: Marc Castrechini | last post by:
I have a page that changes an <ASP:Checkbox value based on a user entered value in a textboxm using client side Javascript. After my submit is fired the value for the chkMyCB.checked does not get...
15
by: Adam J. Schaff | last post by:
I have noticed that if a user closes a form via pressing return (either while the OK button has focus or if AcceptButton is set to OK for the form) then the "ENTER" keypress event fires ON THE...
1
by: Tom S. | last post by:
Hello all, I have a page that contains two listboxes and an "Add" button. When clicked, the button fires javascript that moves the selected item(s) in the first listbox to the second listbox and...
1
by: Joey | last post by:
I have an asp.net 1.1/C# web form with a text box server control and one button server control. Users can type in text to search and then click the button to start the search. I want them to be...
3
by: Bob Sanderson | last post by:
I have a PHP web page which uses a HTML form. I would like to enter dates into the date fields using a JavaScript calendar, similar to the way phpMyAdmin does. Can anyone recommend a JavaScript...
5
by: Paul Lautman | last post by:
Hi y'all, In IE using this trick onKeyDown="if (window.event.keyCode==13) window.event.keyCode=9; (from http://support.microsoft.com/default.aspx/kb/828907) I can cause an enter key press in an...
2
by: newbiegalore | last post by:
Hello everyone I have just finished going through some tutorials on developing extensions for mozilla and have made a version of the born-geek toolbar. Being a newbie I am stuck at a relatively...
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.