How do i capture a 'backspace' or 'delete' keyboard press event?

This thread was migrated from an old forum. It may contain information that are no longer valid. For further assistance, please post a new question or open a support ticket from the Customer Support portal.

I have tried using .keyCode, .key, .code, .which but none of them works.

example:

if(frmName.txtboxName.keyCode!=8){ //do something}

@Bwivn Mowwison​ : Can you please explain your use case on why you need this?

@Blvnkv Busxy​ I need to have a limit on the amount of numbers a user can enter in textbox. MaxLength only applies to text and not numbers so I am looking for a work-around to achieve this. So, am I able to capture the keycode when a user presses a key?

@Bwivn Mowwison​ : If I have to do it I would listen to the text being entered or removed using the event "onTextChange". Then on the text I would have either a regex or some code to check if the text meets the requirement.

exactly, that is what i am doing. But once the user meets the requirement then they are unable to edit the textbox again, which is why i need to take backspace and delete into consideration.

@Blvnkv Busxy

Hi ,

Please share the product version which you are using and Sample App

Hi,

I am using Kony Enterprise version 8 service pack 4 fix pack 5.

Unfortunately I do not have a sample app to share.

@Advm Avewy​ am i able to capture keycode?

@Bwivn Mowwison​ : Are you disabling the text box when the requirement is met?

no, but i was able to find a workaround by using the onkeyup method, thanks

@Bwivn Mowwison​ : Can you please share just the code?

@Blvnkv Busxy

How can I get the keycode of the delete button on the device?

I have added an issue on this issue.

https://basecamp.kony.com/s/question/0D52K000048Ge7GSAS/how-to-handle-device-delete-button-on-device-in-kony