key press event input control

Hi guys,

I only want to know whether it’s possible to add a custom event to an input field to support a “key press” event. I have googled and i have found some solutions for the ‘touch’ version, but nothing for the standard one (goo.gl/yxLhP).

Any way to get it?

Thx in advance.

Unfortunately there is no any event that controls key pressing.

May suggest you to try to use onChange event to control the focus on a needed input.
http://docs.dhtmlx.com/doku.php?id=dhtmlxform:event_onchange

Thanks sematik,

I’m using what you suggest right now, but what I need is to control when someone is typing something in an input box to enable a button. When using onchange event you have to wait until user leaves the control, that is, when the user moves to another element. So, the user experience is not very good in this sense, because while typing, the button is still disabled.

Anyway thanks for your time!

In that case you may try to use onBeforeChange event to control the moment when user begins to change a value of an input:
docs.dhtmlx.com/doku.php?id=dhtm … forechange

Thanks again sematik!

I tried that one too before to post, but it doesn’t fit my needs. The only difference using that event handler is that you can process what user typed before he/she leaves the field and cancel it if you want. So it’s the same for me, because I need to enable a button when the user starts to type in the input and i can’t afford it in this way :frowning:

Is there any way to request this event to be included in future releases?

CU!

Also you can use getInput(name) method to get a typical input into your form so you can use onKeyPress event.
http://docs.dhtmlx.com/doku.php?id=dhtmlxform:api_method_dhtmlxform_getinput

sematik, you made my day! that’s what i was looking for!

This is the code (using JQuery) to get the keyup event (finally I needed keyup) working in an input belonging to a dhtmlxform:

$(this.form.getInput(fieldName)).keyup(this.form_onKeyUp.bind(this))

Where this.form is a DHTMLXFORM object inside a custom object I defined, and this.form_onKeyUp is a function handling the event:

myobject.prototype.form_onKeyUp = function (event) { ... }

Where event is an object containing info from the event api.jquery.com/category/events/ .

I hope this can help to someone in the future!

Regards!