简体   繁体   English

我如何从“输入”事件中获取最后的输入

[英]How do I get the last thing input from an “input” event

I have been trying to deal with getting the last input in to a text field on an Android app from Javascript. 我一直在尝试处理从Javascript向Android应用程序中的文本字段输入最后输入的问题。

I was originally trying to use the KeyUp, KeyDown and KeyPress events to get the KeyCodes from keyboard input however with android soft keyboards you will get the KeyCode 229 for every key other than backspace, space and enter. 我最初试图使用KeyUp,KeyDown和KeyPress事件从键盘输入中获取KeyCode,但是使用android软键盘,除退格键,空格键和Enter键外,您将为每个键获取KeyCode 229。

So now I am using the onInput event however this just seems to alert me to the fact that something has been input in to a text field and not what that input was. 因此,现在我正在使用onInput事件,但这似乎只是在提醒我以下事实:已在文本字段中输入了某些内容,而不是该输入的内容。

document.getElementById("textarea").addEventListener("input", function (e) {
    ClaroSpeak.KeyHandler(e);
}, false);

Does the input event some how let me know what the last change or key was, eg 'space' 'a' 'F' ect... 输入事件是否使我知道最后的更改或键是什么,例如'space''a''F'ect ...

设置“全局”变量并在其中存储最后一个元素怎么办?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM