mirror of
https://github.com/hodgef/simple-keyboard.git
synced 2025-02-01 02:53:07 +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})`);
|
console.log(`Caret handling started (${this.keyboardDOMClass})`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const { physicalKeyboardHighlightPreventDefault = false } = this.options;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event Listeners
|
* Event Listeners
|
||||||
*/
|
*/
|
||||||
document.addEventListener("keyup", this.handleKeyUp);
|
document.addEventListener("keyup", this.handleKeyUp, physicalKeyboardHighlightPreventDefault);
|
||||||
document.addEventListener("keydown", this.handleKeyDown);
|
document.addEventListener("keydown", this.handleKeyDown, physicalKeyboardHighlightPreventDefault);
|
||||||
document.addEventListener("mouseup", this.handleMouseUp);
|
document.addEventListener("mouseup", this.handleMouseUp);
|
||||||
document.addEventListener("touchend", this.handleTouchEnd);
|
document.addEventListener("touchend", this.handleTouchEnd);
|
||||||
document.addEventListener("select", this.handleSelect);
|
document.addEventListener("select", this.handleSelect);
|
||||||
@ -1268,11 +1270,13 @@ class SimpleKeyboard {
|
|||||||
`Destroying simple-keyboard instance: ${this.currentInstanceName}`
|
`Destroying simple-keyboard instance: ${this.currentInstanceName}`
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const { physicalKeyboardHighlightPreventDefault = false } = this.options;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove document listeners
|
* Remove document listeners
|
||||||
*/
|
*/
|
||||||
document.removeEventListener("keyup", this.handleKeyUp);
|
document.removeEventListener("keyup", this.handleKeyUp, physicalKeyboardHighlightPreventDefault);
|
||||||
document.removeEventListener("keydown", this.handleKeyDown);
|
document.removeEventListener("keydown", this.handleKeyDown, physicalKeyboardHighlightPreventDefault);
|
||||||
document.removeEventListener("mouseup", this.handleMouseUp);
|
document.removeEventListener("mouseup", this.handleMouseUp);
|
||||||
document.removeEventListener("touchend", this.handleTouchEnd);
|
document.removeEventListener("touchend", this.handleTouchEnd);
|
||||||
document.removeEventListener("select", this.handleSelect);
|
document.removeEventListener("select", this.handleSelect);
|
||||||
|
@ -29,6 +29,7 @@ class PhysicalKeyboard {
|
|||||||
|
|
||||||
if(options.physicalKeyboardHighlightPreventDefault){
|
if(options.physicalKeyboardHighlightPreventDefault){
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
event.stopImmediatePropagation();
|
||||||
}
|
}
|
||||||
|
|
||||||
const buttonPressed = this.getSimpleKeyboardLayoutKey(event);
|
const buttonPressed = this.getSimpleKeyboardLayoutKey(event);
|
||||||
@ -94,6 +95,7 @@ class PhysicalKeyboard {
|
|||||||
|
|
||||||
if(options.physicalKeyboardHighlightPreventDefault){
|
if(options.physicalKeyboardHighlightPreventDefault){
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
event.stopImmediatePropagation();
|
||||||
}
|
}
|
||||||
|
|
||||||
const buttonPressed = this.getSimpleKeyboardLayoutKey(event);
|
const buttonPressed = this.getSimpleKeyboardLayoutKey(event);
|
||||||
|
Loading…
Reference in New Issue
Block a user