以编程方式将密钥发送到输入字段? [英] Programmatically sending keys to input field?

查看:84
本文介绍了以编程方式将密钥发送到输入字段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为一个带有自定义键盘的机顶盒编写了一个web门户。



键盘有大部分标准字符键,但没有退格键! / p>

由于还有一些免费的自定义键,我想将其中的一个映射到退格,当我在输入字段或文本区域时。



现在的问题是:我如何编程方式发送退格输入字段



或与此有关:如何做我以编程方式发送任意键(如箭头键)输入字段?


解决方案

如果你在一个网络浏览器,不能伪造真正的输入事件,如键盘和鼠标事件(出于安全原因)。



但是,您将能够检测到正在按下的其他自定义键,可以响应你想要使用的键的onKeyDown事件,并在检测到它被按下时更新输入字段...

I'm coding a web-portal for a set top box with a custom keyboard.

The keyboard has most of the standard character keys but no backspace!

Since there are some other free custom keys, I would like to map one of these to backspace when I'm in an input field or in a text area.

The question is: How do I programmatically send a backspace to the input field?

Or for that matter: How do I programmatically send any key (like an arrow key) to the input field?

解决方案

If you are in a web browser, you can't fake real input events like keyboard and mouse events (for security reasons).

However, you will be able to detect the other custom keys being press, so you could respond to the onKeyDown event for the key you want to use and just update the input field when you detect it being pressed...

这篇关于以编程方式将密钥发送到输入字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆