HTML Mobile -forcing the soft keyboard to hide

前端 未结 8 2075
时光说笑
时光说笑 2020-11-27 03:40

I am developing the front end site for a coupon company, and I have a page where the user only needs to input phone number and $$ spent. We came up with a fun on-screen keyb

8条回答
  •  被撕碎了的回忆
    2020-11-27 04:10

    Since the soft keyboard is part of the OS, more often than not, you won't be able to hide it - also, on iOS, hiding the keyboard drops focus from the element.

    However, if you use the onFocus attribute on the input, and then blur() the text input immediately, the keyboard will hide itself and the onFocus event can set a variable to define which text input was focused last.

    Then alter your on-page keyboard to only alter the last-focused (check using the variable) text input, rather than simulating a key press.

提交回复
热议问题