473,507 Members | 3,678 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Capture Enter Key...

10 New Member
Hello,

I'm developing a website using PHP, Javascript and MySQL.

I have a login form with a couple of textboxes and a login button. What I
want to do is capture the Enter key so that when the user presses Enter, it will behave like tab and throw the onchange event (written for each field).

I have searched the Internet for hours now trying to find out how to do it,
but any methods that I have seen do not work.

Can anyone help me do that?

Regards,
Sourav
Jul 9 '08 #1
5 14825
hsriat
1,654 Recognized Expert Top Contributor
Expand|Select|Wrap|Line Numbers
  1. document.body.onkeypress = function (event) {
  2.     event = event || window.event;
  3.     if (event.keycode = 13) {
  4.         alert('Enter key pressed');
  5.         return false;
  6.     }
  7.     return true;
  8. }
Jul 9 '08 #2
sourav08
10 New Member
Expand|Select|Wrap|Line Numbers
  1. document.body.onkeypress = function (event) {
  2.     event = event || window.event;
  3.     if (event.keycode = 13) {
  4.         alert('Enter key pressed');
  5.         return false;
  6.     }
  7.     return true;
  8. }
Hello...

Thanks for ur valuable reply...
Jul 9 '08 #3
hsriat
1,654 Recognized Expert Top Contributor
Hello...

Thanks for ur valuable reply...
You are welcome. I hope you have manipulated it according to your needs.
Jul 9 '08 #4
Prakashs
2 New Member
Hey Folks,

I'm write it using JQuery as follows..

Expand|Select|Wrap|Line Numbers
  1. $(selector).live('keydown', function(e) {
  2.         var key = e.which||e.keyCode;     
  3.         //var key = (window.event) ? e.keyCode : e.which; 
  4.         //var key = (window.event) ? window.event.keyCode : e.which; 
  5.     if (key == 13) {
  6.         alert('Enter key pressed');
  7.         return false;
  8.     }
  9.     return true;
  10. });
Jul 2 '10 #5
Prakashs
2 New Member
@hsriat
Here single assignment(=) is used instead of equal of (==), Actually keycode can work but keyCode is actual..
Jul 2 '10 #6

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

Similar topics

2
3004
by: PA | last post by:
Hi, Can anyone tell me how to capture events of iframes like keypress. I have an editable iframe. When I hit <enter> it actually prints <p> instead of <br>. (innerHTML) Does anyone know how...
1
3074
by: Matthew Wieder | last post by:
Hi - I wanted to capture the enter button on a form since I have a datagrid with the first column being a delete button and if someone hits enter it deletes the first record. I coded: private...
2
2003
by: marcia | last post by:
How can I capture (i.e., write an event handler) that runs after I press the "Enter" key? I'd like to prevent a Web Form from being submitted when the "Enter" key is pressed following the typing...
5
3111
by: ewillyb | last post by:
Hi, ASP.NET has some interesting behavior when the user hits the Enter key. If there are multiple ASP:Buttons (rendered as HTML submits) on the form, when the user hits enter, the first button's...
7
62033
by: Bob Achgill | last post by:
When I use the code for KeyPress to capture pressing a certain key for processing on a form with no Text Box it works. But when I try the same code on my application that has text boxes it does...
3
13882
by: Melson | last post by:
hi can anyone help me how can i capture ENTER keystroke when the cell in datagrid is in editing mode. I'm now creating a data entry form with primary key in header and details in datagrid. So...
4
1444
by: sck10 | last post by:
Hello, I want to allow all users on our company intranet (domain\handle) to enter our website. However, I would like to capture the handle of the person entering my website. I was told that if...
3
2272
by: GS | last post by:
If I were to capture enter key on keyup event of an GUI object like comboBox box, How do I avoid killing ctrol-c, controlv, controlx, shift-insert, shiftdelete, contrl-insert
1
3826
xarzu
by: xarzu | last post by:
How do I capture the event in a CEdit control when the user presses enter or return in a dialog box? I have so far figured out how to disable the event when the user hits return which normally would...
0
7223
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7314
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,...
1
7030
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
5623
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,...
1
5041
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
4702
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1540
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
758
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.