Hello,
we try to write an event based JavaScript function. The function is bound to the "onkeyup"-event of a textbox:
ecc.dateChecker(this);
So the function is called after every keystroke. But in our function we have to know which key was pressed. Also we need to know, on which position in the field the cursor is.
Can you help us?
Dieter
What key is pressed?
-
- Experienced User
- Posts: 122
- Joined: Tue May 22, 2012 6:45 am
- First Name: Dieter
- Last Name: Schröder
- Company Name: Ecclesia Holding GmbH
- State / Province: Outside Canada/USA
- Country: Germany
- Contact:
-
- Experienced User
- Posts: 2711
- Joined: Wed Aug 01, 2012 8:58 am
- First Name: Scott
- Last Name: Klement
- Company Name: Profound Logic
- City: Milwaukee
- State / Province: Wisconsin
Re: What key is pressed?
If you set your onkeyup event to the name of a JavaScript function (instead of setting it to the actual code to run) it will call that function and pass two parameters:
http://www.profoundlogic.com/docs/displ ... eyup+event
More info on the getCursorPosition() API:
http://www.profoundlogic.com/docs/displ ... lement+%29
- The browser's "event" object. This has a subfield for the key code that you can use.
- A reference to the DOM element that the event fired in. You can pass this to our getCursorPosition() API to get the cursor position.
http://www.profoundlogic.com/docs/displ ... eyup+event
More info on the getCursorPosition() API:
http://www.profoundlogic.com/docs/displ ... lement+%29
-
- Experienced User
- Posts: 122
- Joined: Tue May 22, 2012 6:45 am
- First Name: Dieter
- Last Name: Schröder
- Company Name: Ecclesia Holding GmbH
- State / Province: Outside Canada/USA
- Country: Germany
- Contact:
Re: What key is pressed?
Hello Scott,
thank you very much. It is exactly what i am looking for.
Dieter
thank you very much. It is exactly what i am looking for.
Dieter
Who is online
Users browsing this forum: No registered users and 2 guests