Fixed issue in preventMouseDownDefault

This commit is contained in:
Francisco Hodge 2019-09-26 11:13:43 -04:00
parent 0872203d9e
commit a3240e4315

View File

@ -307,6 +307,16 @@ class SimpleKeyboard {
this.options.onKeyReleased(button);
}
/**
* Handles container mousedown
*/
handleKeyboardContainerMouseDown(e) {
/**
* Handle event options
*/
if (this.options.preventMouseDownDefault) e.preventDefault();
}
/**
* Handles button hold
*/
@ -1271,7 +1281,7 @@ class SimpleKeyboard {
this.initialized = true;
/**
* Handling onpointerup
* Handling parent events
*/
/* istanbul ignore next */
if (
@ -1280,17 +1290,24 @@ class SimpleKeyboard {
!useMouseEvents
) {
document.onpointerup = () => this.handleButtonMouseUp();
this.keyboardDOM.onpointerdown = e =>
this.handleKeyboardContainerMouseDown(e);
} else if (useTouchEvents) {
/**
* Handling ontouchend, ontouchcancel
*/
document.ontouchend = () => this.handleButtonMouseUp();
document.ontouchcancel = () => this.handleButtonMouseUp();
this.keyboardDOM.ontouchstart = e =>
this.handleKeyboardContainerMouseDown(e);
} else if (!useTouchEvents) {
/**
* Handling mouseup
*/
document.onmouseup = () => this.handleButtonMouseUp();
this.keyboardDOM.onmousedown = e =>
this.handleKeyboardContainerMouseDown(e);
}
/**