wiki: document press and release bindings
Browse files at this commitb345b12a1122e816b2449bd0c83dd5b9f92f9b02Parent: 9828c092 changed files +76 -1
docs/wiki/Configuration:-Key-Bindings.mdmodified+61 -0
| @@ -100,6 +100,67 @@ binds { | ||
| 100 | 100 | |
| 101 | 101 | This is mostly useful for the scroll bindings. |
| 102 | 102 | |
| 103 | +### Press and Release Bindings | |
| 104 | + | |
| 105 | +<sup>Since: next release</sup> | |
| 106 | + | |
| 107 | +Binds can be set to trigger on key press, on key release, or both. | |
| 108 | +By default, binds trigger on key press. | |
| 109 | +You can change it using `press {}` and `release {}` blocks: | |
| 110 | + | |
| 111 | +```kdl | |
| 112 | +binds { | |
| 113 | + // Trigger on press (default behavior). | |
| 114 | + Mod+T { spawn "alacritty"; } | |
| 115 | + | |
| 116 | + // Trigger on release. | |
| 117 | + // Press and release Mod by itself to open the overview. | |
| 118 | + Mod { | |
| 119 | + release { toggle-overview; } | |
| 120 | + } | |
| 121 | + | |
| 122 | + // Trigger on both press and release with different actions. | |
| 123 | + // | |
| 124 | + // If the press action runs, the release action is guaranteed to run, | |
| 125 | + // no matter how you release the keys. | |
| 126 | + // You can safely use these binds for things like push-to-talk. | |
| 127 | + Control_R { | |
| 128 | + press { spawn "notify-send" "Enable push-to-talk"; } | |
| 129 | + release { spawn "notify-send" "Disable push-to-talk"; } | |
| 130 | + } | |
| 131 | + | |
| 132 | + // Release binds trigger only if you don't press anything else in between. | |
| 133 | + // So, an Alt+Shift bind like this still lets you hit | |
| 134 | + // Alt+Shift+arrows and other shortcuts in applications. | |
| 135 | + Alt+Shift { | |
| 136 | + release { switch-layout "next"; } | |
| 137 | + } | |
| 138 | +} | |
| 139 | +``` | |
| 140 | + | |
| 141 | +Release bindings are especially useful when you want to bind a modifier key. | |
| 142 | +A normal press bind would effectively prevent you from having any other bind containing that modifier. | |
| 143 | + | |
| 144 | +Release-only binds only trigger when you don't press anything else while holding it. | |
| 145 | +If you have a release-only `Mod` bind from the example above, and press any other key or mouse button while holding `Mod`, the bind will not trigger (the overview won't open). | |
| 146 | + | |
| 147 | +In bindings with both press and release, the release action is guaranteed to trigger if the press action triggers. | |
| 148 | +So, your push-to-talk press-release binding will never get stuck pressed, no matter how you release the keys. | |
| 149 | + | |
| 150 | +By default, any bind with both press and release action does not repeat. | |
| 151 | +You can explicitly set `repeat=true` if needed: | |
| 152 | + | |
| 153 | +```kdl | |
| 154 | +binds { | |
| 155 | + // Doesn't repeat automatically | |
| 156 | + // because it has a release {} section. | |
| 157 | + Mod+Shift+Q repeat=true { | |
| 158 | + press { spawn "notify-send" "Pressed (repeating)"; } | |
| 159 | + release { spawn "notify-send" "Released"; } | |
| 160 | + } | |
| 161 | +} | |
| 162 | +``` | |
| 163 | + | |
| 103 | 164 | ### Scroll Bindings |
| 104 | 165 | |
| 105 | 166 | You can bind mouse wheel scroll ticks using the following syntax. |
resources/default-config.kdlmodified+15 -1
| @@ -401,7 +401,21 @@ binds { | ||
| 401 | 401 | // Open/close the Overview: a zoomed-out view of workspaces and windows. |
| 402 | 402 | // You can also move the mouse into the top-left hot corner, |
| 403 | 403 | // or do a four-finger swipe up on a touchpad. |
| 404 | - Mod+O repeat=false { toggle-overview; } | |
| 404 | + // | |
| 405 | + // This is a release bind. | |
| 406 | + // Press and release Mod by itself to trigger it. | |
| 407 | + Mod { | |
| 408 | + release { toggle-overview; } | |
| 409 | + } | |
| 410 | + | |
| 411 | + // You can also bind both press and release actions like so. | |
| 412 | + // If the press action fires, the release action | |
| 413 | + // is also guaranteed to fire. | |
| 414 | + // This is useful for binds like push-to-talk. | |
| 415 | + // Alt+Shift { | |
| 416 | + // press { spawn "notify-send" "Enable push-to-talk!"; } | |
| 417 | + // release { spawn "notify-send" "Disable push-to-talk!"; } | |
| 418 | + // } | |
| 405 | 419 | |
| 406 | 420 | Mod+Q repeat=false { close-window; } |
| 407 | 421 | Alt+F4 repeat=false { close-window; } |