有没有人对(Android)WebView中的contenteditable和keycodes有任何经验?
我正在使用WebView编写Android应用,需要监控关键事件。我使用的是jQuery,所以我使用的是$(document).on('keydown')
。
问题是,收到的事件只包含有用信息,如果它是keyCode 13 /' Enter'。退格,删除或常规字符(我需要能够监控的所有内容)返回值229和“未识别的”#。
我的调试输出如下所示:
e = {"originalEvent":{"isTrusted":true},"type":"keydown","target":{"sizzle1500307408528":{"undefined":{"parentNode":[5,3,true]}}},"currentTarget":{"sizzle1500307408528":{"undefined":{"parentNode":[5,3,true]}}},"timeStamp":5361.655000000001,"jQuery310027283423097243387":true,"delegateTarget":{"location":{"ancestorOrigins":{},"origin":"file://","protocol":"file:","host":"","hostname":"","port":"","search":"","hash":""},"jQuery3100272834230972433871":{"events":{"touchend":[{"type":"touchend","origType":"touchend","guid":1,"selector":".script p","needsContext":false,"namespace":""}],"touchstart":[{"type":"touchstart","origType":"touchstart","guid":2,"selector":".script p","needsContext":false,"namespace":""}],"touchmove":[{"type":"touchmove","origType":"touchmove","guid":3,"selector":".script p","needsContext":false,"namespace":""}],"focusin":[{"type":"focusin","origType":"focus","guid":4,"selector":".script","needsContext":false,"namespace":""}],"focusout":[{"type":"focusout","origType":"blur","guid":5,"selector":".script","needsContext":false,"namespace":""}],"paste":[{"type":"paste","origType":"paste","guid":6,"selector":".script","needsContext":false,"namespace":""}],"selectionchange":[{"type":"selectionchange","origType":"selectionchange","guid":7,"namespace":""}],"input":[{"type":"input","origType":"input","guid":8,"selector":".script","needsContext":false,"namespace":""}],"keydown":[{"type":"keydown","origType":"keydown","guid":9,"selector":".script","needsContext":false,"namespace":""}]},"focusin":1,"focusout":1}},"handleObj":{"type":"keydown","origType":"keydown","guid":9,"selector":".script","needsContext":false,"namespace":""}}
e.keyCode = 229
e.key = Unidentified
我的推测是,229(或0xe5)正在返回,因为那是“过程”#39;与IME输入(as per MDN)相关的keyCode。但无论如何我都没有办法获得关键价值。
(我也很好奇为什么e.KeyCode和e.keyEvent是e的转储中没有keyCode或keyEvent的值。但是可能是另一天的问题。)