mirror of
https://github.com/hodgef/simple-keyboard.git
synced 2025-01-20 01:22:59 +08:00
Adjust physicalKeyboardHighlightPreventDefault per #1841
This commit is contained in:
parent
f6a72b27b2
commit
65a506a2a4
@ -1094,11 +1094,13 @@ class SimpleKeyboard {
|
||||
console.log(`Caret handling started (${this.keyboardDOMClass})`);
|
||||
}
|
||||
|
||||
const { physicalKeyboardHighlightPreventDefault = false } = this.options;
|
||||
|
||||
/**
|
||||
* Event Listeners
|
||||
*/
|
||||
document.addEventListener("keyup", this.handleKeyUp);
|
||||
document.addEventListener("keydown", this.handleKeyDown);
|
||||
document.addEventListener("keyup", this.handleKeyUp, physicalKeyboardHighlightPreventDefault);
|
||||
document.addEventListener("keydown", this.handleKeyDown, physicalKeyboardHighlightPreventDefault);
|
||||
document.addEventListener("mouseup", this.handleMouseUp);
|
||||
document.addEventListener("touchend", this.handleTouchEnd);
|
||||
document.addEventListener("select", this.handleSelect);
|
||||
@ -1268,11 +1270,13 @@ class SimpleKeyboard {
|
||||
`Destroying simple-keyboard instance: ${this.currentInstanceName}`
|
||||
);
|
||||
|
||||
const { physicalKeyboardHighlightPreventDefault = false } = this.options;
|
||||
|
||||
/**
|
||||
* Remove document listeners
|
||||
*/
|
||||
document.removeEventListener("keyup", this.handleKeyUp);
|
||||
document.removeEventListener("keydown", this.handleKeyDown);
|
||||
document.removeEventListener("keyup", this.handleKeyUp, physicalKeyboardHighlightPreventDefault);
|
||||
document.removeEventListener("keydown", this.handleKeyDown, physicalKeyboardHighlightPreventDefault);
|
||||
document.removeEventListener("mouseup", this.handleMouseUp);
|
||||
document.removeEventListener("touchend", this.handleTouchEnd);
|
||||
document.removeEventListener("select", this.handleSelect);
|
||||
|
@ -29,6 +29,7 @@ class PhysicalKeyboard {
|
||||
|
||||
if(options.physicalKeyboardHighlightPreventDefault){
|
||||
event.preventDefault();
|
||||
event.stopImmediatePropagation();
|
||||
}
|
||||
|
||||
const buttonPressed = this.getSimpleKeyboardLayoutKey(event);
|
||||
@ -94,6 +95,7 @@ class PhysicalKeyboard {
|
||||
|
||||
if(options.physicalKeyboardHighlightPreventDefault){
|
||||
event.preventDefault();
|
||||
event.stopImmediatePropagation();
|
||||
}
|
||||
|
||||
const buttonPressed = this.getSimpleKeyboardLayoutKey(event);
|
||||
|
Loading…
Reference in New Issue
Block a user