Page 1 of 1

Disable the Enter Key

Posted: Wed Aug 09, 2017 2:43 pm
by brianhd71
I want to share a solution we had for rerouting our older Dealer Management Solution to a new tech stack and switch seamlessly between the two. We came across an issue where we needed to disable the Enter key to avoid a post back to the IBM i Apache server. In our case, we were attempting to direct our workflow to a new Angular/.Net stack. It worked fine when clicking on the button to the new app, and also when using a combo box selection, however, when the user would key in a '2' for the app on the new stack, the screen would display the old version of our app instead of going directly to our new Angular page. We wrote in to Profound for a solution and Niral Pokal directed us to the preventEvent(event) api to use on the onkeydown event.
The example code we used was:
var code = event.keyCode || event.which;
if(code == 13){
var value = get(this);
if (value == '2' || value == '02'){
preventEvent(event);
}
}
This successfully disabled the Enter key when the selection was a 2 in our app combo box. I would post pictures, but company propriety and all. There are not a lot of cases I can think of where you would want to disable a key, but here is a great example of one.
Here is the documentation for it: http://www.profoundlogic.com/docs/pages ... Id=3276831