Skip to content

Implement fix: KeyboardHelper may damage site functionality #796

@fmiu-imperosoftware

Description

@fmiu-imperosoftware

The KeyboardHelper may brake site functionality because it add/remove document keyboard event listeners using event handlers properties. If the parent site has already some event listeners added in the same manner they are removed by this code and the site functionality is damaged.

  GrabKeyInput (): any {
    if (this.KeyInputGrab) { return }
    document.onkeyup = this.handleKeyUp.bind(this)
    document.onkeydown = this.handleKeyDown.bind(this)
    document.onkeypress = this.handleKeys.bind(this)
    this.KeyInputGrab = true
  }
  UnGrabKeyInput (): any {
    if (!this.KeyInputGrab) { return }
    document.onkeyup = null
    document.onkeydown = null
    document.onkeypress = null
    this.KeyInputGrab = false
  }

Using addEventListener/removeEventListener would be better, to preserve any previous event handlers.

constructor () 
    this.handleKeyUp = this.handleKeyUp.bind(this)

GrabKeyInput
    document.addEventListener('keyup', this.handleKeyUp)

UnGrabKeyInput 
    document.removeEventListener('keyup', this.handleKeyUp)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Todo

    Status

    Q1 2026

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions