Skip to content
This repository has been archived by the owner on Apr 1, 2020. It is now read-only.

Input - Keyboard: Clean up & generalize key handling #2

Closed
bryphe opened this issue Nov 24, 2016 · 2 comments
Closed

Input - Keyboard: Clean up & generalize key handling #2

bryphe opened this issue Nov 24, 2016 · 2 comments

Comments

@bryphe
Copy link
Member

bryphe commented Nov 24, 2016

In keyboard.ts, there is a giant switch for handling various keycodes. This isn't maintainable to handle new scenarios, and there are several keys that are currently not supported.

Some keys that should be supported:

  • VolumeUp/VolumeDown
  • ScrollLock
  • Delete
@Bretley
Copy link
Contributor

Bretley commented Dec 4, 2016

I'm not a huge TS/JS guy at all, but what would you use besides a switch to handle the keycodes?

@bryphe
Copy link
Member Author

bryphe commented Dec 5, 2016

@bert88sta - sorry, this issue wasn't very clear :)

In retrospect the switch really isn't too bad... The bigger problem is that there are a bunch of hardcoded keybindings, like in index.tsx:

        if (key === "<f3>") {
            formatter.formatBuffer()
            return
        }

        if (UI.isPopupMenuOpen()) {
            if (key === "<esc>") {
                UI.hidePopupMenu()
            } else if (key === "<enter>") {
                UI.selectPopupMenuItem(false)
            } else if (key === "<C-v>") {
                UI.selectPopupMenuItem(true)
            } else if (key === "<C-n>") {
                UI.nextPopupMenuItem()
            } else if (key === "<C-p>") {
                UI.previousPopupMenuItem()
            }

            return
        }

So making those configurable is a more pressing issue, since I'm sure my random defaults that work for me aren't for everyone :)

There's some good discussion on this in #20 - I'm going to close this one in favor of that, since that has more details about that problem and potential solutions.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants