mirror of
https://github.com/hodgef/simple-keyboard.git
synced 2025-02-22 01:29:39 +08:00
Add physicalKeyboardHighlightPreventDefault. Fixes #1841
This commit is contained in:
parent
fe53a2c2a7
commit
72470cdea5
@ -109,6 +109,7 @@ class SimpleKeyboard {
|
|||||||
* @property {string} physicalKeyboardHighlightBgColor Define the background 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} physicalKeyboardHighlightPressUseClick Whether physicalKeyboardHighlightPress should use clicks to trigger buttons.
|
||||||
* @property {boolean} physicalKeyboardHighlightPressUsePointerEvents Whether physicalKeyboardHighlightPress should use pointer events 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} preventMouseDownDefault Calling preventDefault for the mousedown events keeps the focus on the input.
|
||||||
* @property {boolean} preventMouseUpDefault Calling preventDefault for the mouseup events.
|
* @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.
|
* @property {boolean} stopMouseDownPropagation Stops pointer down events on simple-keyboard buttons from bubbling to parent elements.
|
||||||
|
@ -161,6 +161,11 @@ export interface KeyboardOptions {
|
|||||||
*/
|
*/
|
||||||
physicalKeyboardHighlightBgColor?: string;
|
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.
|
* Calling preventDefault for the mousedown events keeps the focus on the input.
|
||||||
*/
|
*/
|
||||||
|
@ -26,6 +26,11 @@ class PhysicalKeyboard {
|
|||||||
|
|
||||||
handleHighlightKeyDown(event: KeyboardEvent) {
|
handleHighlightKeyDown(event: KeyboardEvent) {
|
||||||
const options = this.getOptions();
|
const options = this.getOptions();
|
||||||
|
|
||||||
|
if(options.physicalKeyboardHighlightPreventDefault){
|
||||||
|
event.preventDefault();
|
||||||
|
}
|
||||||
|
|
||||||
const buttonPressed = this.getSimpleKeyboardLayoutKey(event);
|
const buttonPressed = this.getSimpleKeyboardLayoutKey(event);
|
||||||
|
|
||||||
this.dispatch((instance: any) => {
|
this.dispatch((instance: any) => {
|
||||||
@ -86,6 +91,11 @@ class PhysicalKeyboard {
|
|||||||
|
|
||||||
handleHighlightKeyUp(event: KeyboardEvent) {
|
handleHighlightKeyUp(event: KeyboardEvent) {
|
||||||
const options = this.getOptions();
|
const options = this.getOptions();
|
||||||
|
|
||||||
|
if(options.physicalKeyboardHighlightPreventDefault){
|
||||||
|
event.preventDefault();
|
||||||
|
}
|
||||||
|
|
||||||
const buttonPressed = this.getSimpleKeyboardLayoutKey(event);
|
const buttonPressed = this.getSimpleKeyboardLayoutKey(event);
|
||||||
|
|
||||||
this.dispatch((instance: any) => {
|
this.dispatch((instance: any) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user