4coder » Forums » Keyboard Shortcut Chords
McMassiveNZ
6 posts
#21047 Keyboard Shortcut Chords
4 months, 1 week ago Edited by McMassiveNZ on May 14, 2019, 8:14 a.m. Reason: Initial post

Hey Allen/Forum,

I want to implement some keyboard shortcuts that are a combination of multiple shortcuts. For instance Visual studio has the following shortcuts to comment out blocks of code (Ctrl+K Ctrl+C) or to format a block (Ctrl+K Ctrl+F) etc

I was just wondering if anyone has already solved this problem and would like to share the best way to do it before I dive in and start hacking something together :)

Thanks
mrmixer
Simon Anciaux
663 posts
#21048 Keyboard Shortcut Chords
4 months, 1 week ago

You can use key maps to do that. See the modal customization layer example in the wiki.

The idea is that your first shortcut (ctrl + k) changes the key map, and the second (crtl + c) call a function in that key map and reset the key map to the default one.