-
Notifications
You must be signed in to change notification settings - Fork 11
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
Shift + Esc to Tilde Character? #7
Comments
You can use an unused key code for this purpose. So instead of emitting a
You would need two-two down and up events fired, that currently is not possible. I would say you need something like this:
And here is the patch for it: diff --git a/k2k.c b/k2k.c
index 435d1cd..35aac6c 100644
--- a/k2k.c
+++ b/k2k.c
@@ -82,9 +82,9 @@ static struct tap_rule {
*/
static struct multi_rule {
int const keys[8]; /** Keys to watch. */
- int const down_press[2]; /** Press first key and release second key when
+ int const down_press[4]; /** Press first key and release second key when
toggled down. */
- int const up_press[2]; /** Press first key and release second key when
+ int const up_press[4]; /** Press first key and release second key when
toggled up. */
int const nbeforedown; /** Only allow toggling down after this many `keys`
have been down. Negative value means inequality. */
@@ -539,7 +539,7 @@ main(void) {
if (v->can_toggle && (!v->is_down
? ndown == ntotal
: (v->nup >= 0 ? ndown == v->nup : ndown != -v->nup))) {
- int press[2];
+ int press[4];
v->is_down ^= 1;
memcpy(press, v->is_down ? v->down_press : v->up_press, sizeof press);
@@ -555,6 +555,12 @@ main(void) {
if (press[1] != KEY_RESERVED)
write_key_event(press[1], EVENT_VALUE_KEYUP);
+
+ if (press[2] != KEY_RESERVED)
+ write_key_event(press[2], EVENT_VALUE_KEYDOWN);
+
+ if (press[3] != KEY_RESERVED)
+ write_key_event(press[3], EVENT_VALUE_KEYUP);
}
for (j = 0; j < ntotal; ++j) { (Sorry for my laziness, it is absolutely untested.) |
Just curious, but if you don't need the physical escape key (caps2esc, etc.), wouldn't this work if you just map Esc to the Grave character? EDIT: Just tested it, it works. |
I'm trying to put together an inception-k2k rule for my 65% keyboard to get shift+escape bound to the ~ character. My keyboard doesn't have a grave/tilde key, but I use tilde quite often sicne it's the *nix shortcut for home directory. I figured this would be relatively straightfoward, but it turns out that it's made complicated by the fact that ~ isn't a key - it's a character that gets printed when Shift+` is typed.
Based on what I've read from the source code, it doesn't seem possible to write a multibind that targets another multibind, like
The other thought I had was that perhaps I could leverage an external tool to write the character for me, but it appears that we don't have any support for doing something like ydotool calls (the wayland compatible variant of xdotool) in response to keybind being pressed.
Any thoughts on how I could accomplish this particular binding?
The text was updated successfully, but these errors were encountered: