Add physicalKeyboardHighlightPreventDefault. Fixes #1841

This commit is contained in:
Francisco Hodge 2023-01-16 16:46:29 -05:00
parent fe53a2c2a7
commit 72470cdea5
3 changed files with 16 additions and 0 deletions

View File

@ -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.

View File

@ -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.
*/

View File

@ -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) => {