From 78340879922fb401e986640578ea7a711e0e3692 Mon Sep 17 00:00:00 2001 From: Francisco Hodge Date: Tue, 12 Apr 2022 21:12:00 -0700 Subject: [PATCH] Add physicalKeyboardHighlightPressUsePointerEvents. Fixes #1506 --- src/lib/components/Keyboard.ts | 2 ++ src/lib/interfaces.ts | 5 +++++ src/lib/services/PhysicalKeyboard.ts | 5 ++++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/lib/components/Keyboard.ts b/src/lib/components/Keyboard.ts index 470e1b9b..2ea0bdd3 100644 --- a/src/lib/components/Keyboard.ts +++ b/src/lib/components/Keyboard.ts @@ -107,6 +107,8 @@ class SimpleKeyboard { * @property {boolean} physicalKeyboardHighlightPress Presses keys highlighted by physicalKeyboardHighlight * @property {string} physicalKeyboardHighlightTextColor Define the text color that the physical keyboard highlighted key should have. * @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} 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 5f237028..d9c5edce 100644 --- a/src/lib/interfaces.ts +++ b/src/lib/interfaces.ts @@ -145,6 +145,11 @@ export interface KeyboardOptions { */ physicalKeyboardHighlightPressUseClick?: boolean; + /** + * Whether physicalKeyboardHighlightPress should use pointer events to trigger buttons. + */ + physicalKeyboardHighlightPressUsePointerEvents?: boolean; + /** * Define the text color that the physical keyboard highlighted key should have. */ diff --git a/src/lib/services/PhysicalKeyboard.ts b/src/lib/services/PhysicalKeyboard.ts index 27612b7d..1db86788 100644 --- a/src/lib/services/PhysicalKeyboard.ts +++ b/src/lib/services/PhysicalKeyboard.ts @@ -53,7 +53,10 @@ class PhysicalKeyboard { options.physicalKeyboardHighlightTextColor || "black"; if (options.physicalKeyboardHighlightPress) { - if (options.physicalKeyboardHighlightPressUseClick) { + if (options.physicalKeyboardHighlightPressUsePointerEvents) { + buttonDOM.onpointerdown(); + buttonDOM.onpointerup(); + } else if (options.physicalKeyboardHighlightPressUseClick) { buttonDOM.click(); } else { instance.handleButtonClicked(buttonName, event);