diff --git a/src/lib/components/Keyboard.ts b/src/lib/components/Keyboard.ts index 1bf7dece..fc6b773e 100644 --- a/src/lib/components/Keyboard.ts +++ b/src/lib/components/Keyboard.ts @@ -109,6 +109,7 @@ class SimpleKeyboard { * @property {string} physicalKeyboardHighlightBgColor Define the background color that the physical keyboard highlighted key should have. * @property {boolean} physicalKeyboardHighlightPressUseClick Whether physicalKeyboardHighlightPress should use clicks to trigger buttons. * @property {boolean} physicalKeyboardHighlightPressUsePointerEvents Whether physicalKeyboardHighlightPress should use pointer events to trigger buttons. + * @property {boolean} physicalKeyboardHighlightPreventDefault Whether physicalKeyboardHighlight should use preventDefault to disable default browser actions. * @property {boolean} preventMouseDownDefault Calling preventDefault for the mousedown events keeps the focus on the input. * @property {boolean} preventMouseUpDefault Calling preventDefault for the mouseup events. * @property {boolean} stopMouseDownPropagation Stops pointer down events on simple-keyboard buttons from bubbling to parent elements. diff --git a/src/lib/interfaces.ts b/src/lib/interfaces.ts index 30871907..4a8c4dd0 100644 --- a/src/lib/interfaces.ts +++ b/src/lib/interfaces.ts @@ -161,6 +161,11 @@ export interface KeyboardOptions { */ physicalKeyboardHighlightBgColor?: string; + /** + * Whether physicalKeyboardHighlight should use preventDefault to disable default browser actions. + */ + physicalKeyboardHighlightPreventDefault?: boolean; + /** * Calling preventDefault for the mousedown events keeps the focus on the input. */ diff --git a/src/lib/services/PhysicalKeyboard.ts b/src/lib/services/PhysicalKeyboard.ts index 9b89c54d..9978ac34 100644 --- a/src/lib/services/PhysicalKeyboard.ts +++ b/src/lib/services/PhysicalKeyboard.ts @@ -26,6 +26,11 @@ class PhysicalKeyboard { handleHighlightKeyDown(event: KeyboardEvent) { const options = this.getOptions(); + + if(options.physicalKeyboardHighlightPreventDefault){ + event.preventDefault(); + } + const buttonPressed = this.getSimpleKeyboardLayoutKey(event); this.dispatch((instance: any) => { @@ -86,6 +91,11 @@ class PhysicalKeyboard { handleHighlightKeyUp(event: KeyboardEvent) { const options = this.getOptions(); + + if(options.physicalKeyboardHighlightPreventDefault){ + event.preventDefault(); + } + const buttonPressed = this.getSimpleKeyboardLayoutKey(event); this.dispatch((instance: any) => {