Manually triggering the iPhone/iPad/iPod keyboard from JavaScript

后端 未结 7 1187
[愿得一人]
[愿得一人] 2020-11-28 12:34

I am developing an HTML code editor using simple DIV\'s and capturing events. When I use this on the iPad the keyboard never pops up since i\'m not technically in an editab

7条回答
  •  北荒
    北荒 (楼主)
    2020-11-28 13:02

    Place a transparent textarea over the contentEditable div. The keyboard will open, as soon as the user focus the textarea.

    Register an event listener on the textarea for the focus event and set the visibilityof the textarea to hidden. This prevents the blinking cursor.

    Set the visibility of the textarea back to visible after the blur event occurred.

    Register additional event listeners for keydown, keyup, keypressevents and process theses events the same way, as you process them in the contentEditable div.

提交回复
热议问题