How can we hide/close the keyboard when a user clicks away?

Camilo 7 years ago updated by icahill (Administrator) 7 years ago 1
I am working on a page with several textfields. I was able to create a simple action.

action name="keyboard-off"
keyboard visible="no" /

I could also place an underscore variable and make it the same as the alias so that I can target it but this seems unnecessary and tedious since I would have to make a variable for every textfield in my app.


action name="keyboard-off"
keyboard visible="no" target="_example" /

However, I would like the keyboard to close if the user clicks outside the keyboard. I believe this is standard practice.

Currently unless you are using the dismiss button that is native on the keyboard (ipad only) then you do need to identify a target for the textfield that is using the keyboard to dismiss it. You are right on track with the variable solution b/c then you only need a single action to dismiss several textfields.

You can add an onclick="keyboard-off" trigger to other objects that are on the screen when your keyboard is open that will trigger the keyboard to close as long as the target is correct. So it might make sense to move your textfields in a reusable class that can share a single object variable.