Skip to content

Prevent key triggers when focused on input fields #1

@codebyshennan

Description

@codebyshennan

Improvements

Could i suggest the following improvements?

This ensures that the keyDown does not fire when the user is focused on input fields.

document.addEventListener("keypress", function(event) {
  if (event.key === H  && event.target.nodeName.toLowerCase() !== 'input' ) {
    if (getDisplay(navBarSelector) === NONE) {
      console.log('showing navbar')
      showNavbars();
    } else {
      console.log('hiding navbar')
      hideNavbars();
    }
  } 
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions