IPad Disable keyevent on input

点点圈 提交于 2019-12-13 05:39:26

问题


I am working on a solution that implements adding text to textboxes but I disable the normal key events and use a custom one. I disable the key event like this:

<input onkeypress="return false;"  onkeydown="return false;"  onkeyup="return false;" type="text">

Now this works fine on browsers(Safari, Firefox, IE) but it fails to do so on the IPad's Safari and when a user press a key, it is entered twice. Is there another way to disable key events on the input field for the ipad?


回答1:


Maybe you can make the textbox completely transparent (alpha:0), place it inside a div, and add the text to the div behind the textbox.




回答2:


I figured it out. Basically if you are going to customize key entry, you have to customize it on the key up and not the key down or key pressed in Javascript.



来源:https://stackoverflow.com/questions/4975330/ipad-disable-keyevent-on-input

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!