+1

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

Camilo 11 jaar geleden bijgewerkt door icahill (Administrator) 11 jaar geleden 1
I am working on a page with several textfields. I was able to create a simple action.
onreturnkeypressed="keyboard-off"

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

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.

_example=”DATE”

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

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

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.