What key is pressed?

Use this board to ask questions or have discussions with other Rich Displays users.
Post Reply
dieter
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:

What key is pressed?

Post by dieter »

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
Scott Klement
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?

Post by Scott Klement »

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:
  1. The browser's "event" object. This has a subfield for the key code that you can use.
  2. A reference to the DOM element that the event fired in. You can pass this to our getCursorPosition() API to get the cursor position.
More info on the onKeyUp event:
http://www.profoundlogic.com/docs/displ ... eyup+event

More info on the getCursorPosition() API:
http://www.profoundlogic.com/docs/displ ... lement+%29
dieter
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?

Post by dieter »

Hello Scott,

thank you very much. It is exactly what i am looking for.

Dieter
Post Reply

Who is online

Users browsing this forum: No registered users and 15 guests