In newer browsers supporting DOM3
you can use event.location
to check the location.
In the DOM3 spec, there are 4 constants defined for location, DOM_KEY_LOCATION_STANDARD
, DOM_KEY_LOCATION_LEFT
, DOM_KEY_LOCATION_RIGHT
, andDOM_KEY_LOCATION_NUMPAD
.
In this case, you can do:
if (event.location === KeyboardEvent.DOM_KEY_LOCATION_LEFT){
} else if (event.location === KeyboardEvent.DOM_KEY_LOCATION_RIGHT){
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…