[英]Prevent backspace on polymer paper-input
I have a polymer input field like this: 我有一个这样的聚合物输入字段:
<paper-input type="text" class="user-value" data-id="user-value" value="{{typingAns}}" focus maxlength="10" />
is it possible to block the backspace functionality on this input? 是否可以阻止此输入上的退格功能? Basically, if the user press backspace is it possible to keep typingAns the same?
基本上,如果用户按Backspace键,是否可以保持键入相同? I tried to use onkeydown but it doesn't seem to work.
我尝试使用onkeydown,但似乎无法正常工作。
Thanks a lot. 非常感谢。
I actually fix this with: 我实际上用以下方法解决此问题:
preventBackspace : function preventBackspace(){
window.addEventListener("keydown", function(e){
if(e.keyCode === 8) {
e.preventDefault();
console.log('Prevent page from going back');
}
});
}
and 和
typingAnsChanged: function() {
var _this = this;
if (this.typingAns) {
_this.preventBackspace();
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.