Angular 2 键盘事件触发安全按钮

Angular 2 keyboard event triggering safety button

我在 IE11 触发安全按钮时遇到以下代码问题,如下图所示

@Component({
  selector: 'app-component',
})
class AppComponent { 
  @HostListener('window:keydown', ['$event'])
  doSomething($event) {
    // alt + s
    if($event.altKey && $event.altKey === 83) {
        // perform some action
        // saveForm();

        // also added this but still triggering in IE11
        $event.preventDefault();
    }
  }
}

我尝试添加 $event.preventDefault(), $event.stopPropagation(), $event.cancelBubble = true;和其他一些。

我的问题是它在执行 saveForm(); 的同时还触发了 IE11 中的安全按钮。如何阻止安全按钮在 IE 中打开?

使用 accesskey 是解决方案。 https://www.w3schools.com/tags/att_accesskey.asp