我可以通过检查是否使用了 shift 键来区分向上箭头和 & 符号来解决这个问题。
case 38: // up arrow / ampersand
// When used with the shiftKey this is actually the ampersand.
// Don't prevent default or call prev if the shift key is also pressed
if (!e.shiftKey) {
e.preventDefault()
this.prev()
}
break
我还对向下箭头(案例 40)应用了相同的检查,因为它也是由左括号触发的。
case 40: // down arrow / left parenthesis
// When used with the shiftKey this is actually the left parenthesis.
// Don't prevent default or call next if the shift key is also pressed
if (!e.shiftKey){
e.preventDefault()
this.next()
}
break