Adjust physicalKeyboardHighlightPreventDefault per #1841

This commit is contained in:
Francisco Hodge 2023-01-16 19:04:05 -05:00
parent f6a72b27b2
commit 65a506a2a4
2 changed files with 10 additions and 4 deletions

View File

@ -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);

View File

@ -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);