Chrome移动版上的Backspace事件

时间:2017-02-22 01:24:34

标签: javascript google-chrome meteor

此流量事件在磁盘顶级Chrome上运行时按预期运行,但在移动Chrome上运行不佳。  请参阅下面的代码中的注释,无论浏览器何时命中退格键,如何将条件evt.which != 8评估为false? THX

Template.input.events({
  'keyup input[name=email]': function (evt, template) {
    if (evt.which === 13) { // Enter key is pressed
      //do stuff
      }
    }
    else if (evt.which != 8) {
      // backspace button evaluates to false on desktop chrome
      // but evaluests to true on Android chrome.
    }
  }
});

1 个答案:

答案 0 :(得分:1)

大多数台式计算机没有退格键键,它们有 delete 键。 delete 键的关键代码是46。尝试将else if子句更改为以下内容:

else if (evt.which !== 8 && evt.which !== 46) {
    //should fall through to here if not backspace or delete key
}
相关问题