【问题标题】:On key press - not working in Chrome mobile (Android)?按键时 - 在 Chrome 移动版 (Android) 中不起作用?
【发布时间】:2017-09-17 22:00:00
【问题描述】:

我在 Android (8.0.0) 上使用 Google Chrome,onkeypress 没有捕捉到 contenteditable div 上的编辑事件。

<div contenteditable ='true' onkeypress =alert("press")> When ediiting this text, you should get an alert. Does not work on Android chrome. </div>

有什么解决办法吗?

【问题讨论】:

    标签: android html css google-chrome


    【解决方案1】:

    试试onkeydown()

    <div contenteditable='true' onkeydown=alert("press")>Text</div>

    【讨论】:

    • 我的问题是不能返回false来阻止用户输入
    • @DavidSomekh 抱歉,编辑了我的答案。试试onkeydown()
    • 它正在捕获事件,但返回 false 不会阻止用户插入文本。有什么想法吗?
    猜你喜欢
    • 1970-01-01
    • 2013-10-01
    • 2016-01-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-01
    • 1970-01-01
    • 2015-10-09
    相关资源
    最近更新 更多