Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add keyboard shortcuts to common actions in Hajk #257

Open
jacobwod opened this issue Aug 15, 2019 · 1 comment
Open

Add keyboard shortcuts to common actions in Hajk #257

jacobwod opened this issue Aug 15, 2019 · 1 comment
Labels
idea module:client/core Core functionality (not a plugin) optimization
Milestone

Comments

@jacobwod
Copy link
Member

jacobwod commented Aug 15, 2019

Update

The following has been implemented so far:


Idea

The shortcuts should be global, work all the time when Hajk is in focus, except:

  1. When focus is in input fields (e.g. user types search phrase)

Examples of actions that could benefit from shortcuts (in no particular order):

  1. Browse results in infoclick results window. Previous and next are the obvious options.
  2. Pressing S anywhere should put focus in search box.
  3. Perhaps shortcuts that toggle some plugins, e.g. L could toggle LayerSwitcher while P the Print plugin.
  4. Esc to finish/close a measurement or draw action.
  5. [feel free to add more!]

Proposed implementation

Github's HotKey, although other options are possible.

@jacobwod jacobwod added optimization module:client/core Core functionality (not a plugin) labels Aug 15, 2019
@jacobwod jacobwod added this to the 3.x milestone Aug 15, 2019
@jacobwod
Copy link
Member Author

I've done some tests, one very simple in FeatureInfo.js that allows user to browse through infoclick results using keyboard arrows. It's implemented roughly like this:

componentDidMount() {
    []

    // TODO: Optimize. De-activate when not needed.
    window.onkeyup = e => {
      var pressed = e.keyCode;
      switch (pressed) {
        case 37:
          this.changeSelectedIndex(-1);
          break;
        case 39:
          this.changeSelectedIndex(1);
          break;
        default:
          break;
      }
      console.log(pressed);
    };
  }

While this works, I think we should have a more app-wide mechanism for this.

I haven't looked further into it, but there are some libraries, such as react-hotkeys that could work.

@jacobwod jacobwod added the idea label Nov 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
idea module:client/core Core functionality (not a plugin) optimization
Projects
None yet
Development

No branches or pull requests

1 participant