2017-09-17 32 views
0

我在Android(8.0.0)上使用Google Chrome,onkeypress未在contenteditablediv上捕捉編輯事件。按鍵 - 不適用於Chrome移動版(Android)?

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

任何解決方案?

回答

0

嘗試用onkeydown()

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

+0

我的問題是,我不能返回false,以防止用戶輸入 –

+0

@DavidSomekh對不起,編輯我的答案。嘗試'onkeydown()'。 – the4kman

+0

捕捉事件,但返回false並不妨礙用戶插入文本。任何想法? –

相關問題