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 editor in settings #1403



Copy link

rickychandra commented Mar 12, 2019

Closes: #1162
This is the last PR that closes the issue.
I implemented the UI to actually add and remove keyboard shortcuts in the existing "Keyboard" tab in "Insomnia Preferences" modal.


For each defined shortcut action row, I added a button which if clicked, will show the dropdown to add a new keyboard shortcut or remove existing ones (if there are any) options.
Screenshot from 2019-03-13 00-36-38

If the add option is chosen, then a new modal is displayed to capture user's pressed key combinations.
After we have pressed the desired key combination, we can then press enter to save the combination, or esc to discard it and close the modal. This means that we can't have enter and esc as valid shortcuts; IMO they are not very useful either, since almost all shortcuts are listened in global context, so enter will always trigger the shortcut, if pressed. However, adding special keys (ctrl, alt, shift, meta) before enter and esc will be recognized. Incomplete key combination, e.g. ctrl+alt+, will not be saved; pressing enter will discard it and close the modal. These behaviors are made similar to that of VS Code's.

Duplicate key combination is not allowed. There will be an indicator to show the message in the modal bottom.
Screenshot from 2019-03-13 00-49-50

After entering and saving a key combination, it will be immediately displayed in the shortcuts list and take effect without reloading the app, and the same applies for removing a combination.
Screenshot from 2019-03-13 00-37-12
Screenshot from 2019-03-13 00-37-28

There are also options to reset the keyboard shortcuts to the default values. The first one is "Reset All" which will reset all of the shortcuts in the list. The second one can be found in the dropdown, and will only appear if the shortcuts are different from the default ones.
Screenshot from 2019-03-13 01-08-52

Other changes

I removed the shortcuts in Electron's toolbar's menu, because IMO they are redundant and cannot be overridden without reloading the app.
I also added the missing Generate Code and Filter Sidebar shortcuts in the shortcuts list.

Copy link

gschier left a comment

This looks really good! I think we need to keep the shortcuts in the Electron toolbar though. Even if they're just dummy ones for display purposes only. Mac users expect those to be there.

If you add them back, I might be able to hook something up so that they change without reloading the app.

Copy link

gschier left a comment

Going to merge this in for the next release! I'm fine with the missing Electron menu hotkeys for now. I didn't realize before that it was just a few of them.

@gschier gschier merged commit 93e8d70 into Kong:develop Apr 18, 2019
2 checks passed
2 checks passed
continuous-integration/appveyor/pr AppVeyor build succeeded
continuous-integration/travis-ci/pr The Travis CI build passed
gschier added a commit that referenced this pull request Apr 18, 2019
@rickychandra rickychandra deleted the rickychandra:feature/custom-keybindings-editor branch Apr 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.