4coder » Forums » Keyboard Shortcut Chords
6 posts
#21047 Keyboard Shortcut Chords
5 days, 6 hours 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 :)

Simon Anciaux
592 posts
#21048 Keyboard Shortcut Chords
5 days, 1 hour 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.