无论如何是否也有禁用浏览器键盘快捷键的方法吗?Google Chrome键盘快捷键在我的代码之后发生。我只是不想让它走开。
handleKeyDown( e ) {
if ( e.ctrlKey && e.keyCode === 68 ) { // ctrl + d
// this works, BUT it also triggers Google Chrome's bookmark shortcut
}
您应该防止事件的默认操作,例如:
function handleKeyDown( e ) {
if ( e.ctrlKey && e.keyCode === 68 ) { // ctrl + d
// this works, BUT it also triggers Google Chrome's bookmark shortcut
console.log('Ctrl+D');
}
e.preventDefault();
}
https://jsfiddle.net/a5wbd3o9/