我怎样才能让我的输入域就像键盘处于改写模式一样呢?
当用户输入值时,我尝试使用keycode中的delete按钮触发按键事件,但没有任何反应。
发布于 2012-07-16 21:19:36
类似于:
<input onkeydown="this.oldSize = this.value.length;"
onkeypress="var n = this; setTimeout(function() {
if(n.value.length > n.oldSize) {
var s = n.selectionStart;
n.value = n.value.substr(0, s) + n.value.substr(s + 1);
n.selectionStart = n.selectionEnd = s;
}
},10);">发布于 2012-07-16 20:11:33
嗯,我不知道你想要什么,do.maybe这会对你有帮助。
Keymaster是一个简单的(大约100 LoC )微库,用于定义和调度键盘快捷键。它没有依赖项。
https://stackoverflow.com/questions/11503798
复制相似问题