aboutsummaryrefslogtreecommitdiff
path: root/docs/feature_auto_shift.md
diff options
context:
space:
mode:
Diffstat (limited to 'docs/feature_auto_shift.md')
-rw-r--r--docs/feature_auto_shift.md176
1 files changed, 162 insertions, 14 deletions
diff --git a/docs/feature_auto_shift.md b/docs/feature_auto_shift.md
index a54cd79e4..99b0ca3c8 100644
--- a/docs/feature_auto_shift.md
+++ b/docs/feature_auto_shift.md
@@ -26,20 +26,26 @@ down will repeat the shifted key, though this can be disabled with
26once then immediately (within `TAPPING_TERM`) hold it down again (this works 26once then immediately (within `TAPPING_TERM`) hold it down again (this works
27with the shifted value as well if auto-repeat is disabled). 27with the shifted value as well if auto-repeat is disabled).
28 28
29There are also the `get_auto_shift_repeat` and `get_auto_shift_no_auto_repeat`
30functions for more granular control. Neither will have an effect unless
31`AUTO_SHIFT_REPEAT_PER_KEY` or `AUTO_SHIFT_NO_AUTO_REPEAT_PER_KEY` respectively
32are defined.
33
29## Are There Limitations to Auto Shift? 34## Are There Limitations to Auto Shift?
30 35
31Yes, unfortunately. 36Yes, unfortunately.
32 37
33You will have characters that are shifted when you did not intend on shifting, and 381. You will have characters that are shifted when you did not intend on shifting, and
34other characters you wanted shifted, but were not. This simply comes down to 39 other characters you wanted shifted, but were not. This simply comes down to
35practice. As we get in a hurry, we think we have hit the key long enough for a 40 practice. As we get in a hurry, we think we have hit the key long enough for a
36shifted version, but we did not. On the other hand, we may think we are tapping 41 shifted version, but we did not. On the other hand, we may think we are tapping
37the keys, but really we have held it for a little longer than anticipated. 42 the keys, but really we have held it for a little longer than anticipated.
38 432. Additionally, with keyrepeat the desired shift state can get mixed up. It will
39Additionally, with keyrepeat the desired shift state can get mixed up. It will 44 always 'belong' to the last key pressed. For example, keyrepeating a capital
40always 'belong' to the last key pressed. For example, keyrepeating a capital 45 and then tapping something lowercase (whether or not it's an Auto Shift key)
41and then tapping something lowercase (whether or not it's an Auto Shift key) 46 will result in the capital's *key* still being held, but shift not.
42will result in the capital's *key* still being held, but shift not. 473. Auto Shift does not apply to Tap Hold keys. For automatic shifting of Tap Hold
48 keys see [Retro Shift](#retro-shift).
43 49
44## How Do I Enable Auto Shift? 50## How Do I Enable Auto Shift?
45 51
@@ -96,6 +102,34 @@ quicker than normal and you will be set.
96 102
97?> Auto Shift has three special keys that can help you get this value right very quick. See "Auto Shift Setup" for more details! 103?> Auto Shift has three special keys that can help you get this value right very quick. See "Auto Shift Setup" for more details!
98 104
105For more granular control of this feature, you can add the following to your `config.h`:
106
107```c
108#define AUTO_SHIFT_TIMEOUT_PER_KEY
109```
110
111You can then add the following function to your keymap:
112
113```c
114uint16_t get_autoshift_timeout(uint16_t keycode, keyrecord_t *record) {
115 switch(keycode) {
116 case AUTO_SHIFT_NUMERIC:
117 return 2 * get_generic_autoshift_timeout();
118 case AUTO_SHIFT_SPECIAL:
119 return get_generic_autoshift_timeout() + 50;
120 case AUTO_SHIFT_ALPHA:
121 default:
122 return get_generic_autoshift_timeout();
123 }
124}
125```
126
127Note that you cannot override individual keys that are in one of those groups
128if you are using them; trying to add a case for `KC_A` in the above example will
129not compile as `AUTO_SHIFT_ALPHA` is there. A possible solution is a second switch
130above to handle individual keys with no default case and only referencing the
131groups in the below fallback switch.
132
99### NO_AUTO_SHIFT_SPECIAL (simple define) 133### NO_AUTO_SHIFT_SPECIAL (simple define)
100 134
101Do not Auto Shift special keys, which include -\_, =+, [{, ]}, ;:, '", ,<, .>, 135Do not Auto Shift special keys, which include -\_, =+, [{, ]}, ;:, '", ,<, .>,
@@ -109,11 +143,24 @@ Do not Auto Shift numeric keys, zero through nine.
109 143
110Do not Auto Shift alpha characters, which include A through Z. 144Do not Auto Shift alpha characters, which include A through Z.
111 145
112### Auto Shift Per Key 146### Auto Shift Per Key
113 147
114This is a function that allows you to determine which keys shold be autoshifted, much like the tap-hold keys. 148There are functions that allows you to determine which keys shold be autoshifted, much like the tap-hold keys.
115 149
116The default function looks like this: 150The first of these, used to simply add a key to Auto Shift, is `get_custom_auto_shifted_key`:
151
152```c
153bool get_custom_auto_shifted_key(uint16_t keycode, keyrecord_t *record) {
154 switch(keycode) {
155 case KC_DOT:
156 return true;
157 default:
158 return false;
159 }
160}
161```
162
163For more granular control, there is `get_auto_shifted_key`. The default function looks like this:
117 164
118```c 165```c
119bool get_auto_shifted_key(uint16_t keycode, keyrecord_t *record) { 166bool get_auto_shifted_key(uint16_t keycode, keyrecord_t *record) {
@@ -131,9 +178,10 @@ bool get_auto_shifted_key(uint16_t keycode, keyrecord_t *record) {
131# endif 178# endif
132 return true; 179 return true;
133 } 180 }
134 return false; 181 return get_custom_auto_shifted_key(keycode, record);
135} 182}
136``` 183```
184
137This functionality is enabled by default, and does not need a define. 185This functionality is enabled by default, and does not need a define.
138 186
139### AUTO_SHIFT_REPEAT (simple define) 187### AUTO_SHIFT_REPEAT (simple define)
@@ -144,6 +192,106 @@ Enables keyrepeat.
144 192
145Disables automatically keyrepeating when `AUTO_SHIFT_TIMEOUT` is exceeded. 193Disables automatically keyrepeating when `AUTO_SHIFT_TIMEOUT` is exceeded.
146 194
195## Custom Shifted Values
196
197Especially on small keyboards, the default shifted value for many keys is not
198optimal. To provide more customizability, there are two user-definable
199functions, `autoshift_press/release_user`. These register or unregister the
200correct value for the passed key. Below is an example adding period to Auto
201Shift and making its shifted value exclamation point. Make sure to use weak
202mods - setting real would make any keys following it use their shifted values
203as if you were holding the key. Clearing of modifiers is handled by Auto Shift,
204and the OS-sent shift value if keyrepeating multiple keys is always that of
205the last key pressed (whether or not it's an Auto Shift key).
206
207You can also have non-shifted keys for the shifted values (or even no shifted
208value), just don't set a shift modifier!
209
210```c
211bool get_custom_auto_shifted_key(uint16_t keycode, keyrecord_t *record) {
212 switch(keycode) {
213 case KC_DOT:
214 return true;
215 default:
216 return false;
217 }
218}
219
220void autoshift_press_user(uint16_t keycode, bool shifted, keyrecord_t *record) {
221 switch(keycode) {
222 case KC_DOT:
223 register_code16((!shifted) ? KC_DOT : KC_EXLM);
224 break;
225 default:
226 if (shifted) {
227 add_weak_mods(MOD_BIT(KC_LSFT));
228 }
229 // & 0xFF gets the Tap key for Tap Holds, required when using Retro Shift
230 register_code16((IS_RETRO(keycode)) ? keycode & 0xFF : keycode);
231 }
232}
233
234void autoshift_release_user(uint16_t keycode, bool shifted, keyrecord_t *record) {
235 switch(keycode) {
236 case KC_DOT:
237 unregister_code16((!shifted) ? KC_DOT : KC_EXLM);
238 break;
239 default:
240 // & 0xFF gets the Tap key for Tap Holds, required when using Retro Shift
241 // The IS_RETRO check isn't really necessary here, always using
242 // keycode & 0xFF would be fine.
243 unregister_code16((IS_RETRO(keycode)) ? keycode & 0xFF : keycode);
244 }
245}
246```
247
248## Retro Shift
249
250Holding and releasing a Tap Hold key without pressing another key will ordinarily
251result in only the hold. With `retro shift` enabled this action will instead
252produce a shifted version of the tap keycode on release.
253
254It does not require [Retro Tapping](tap_hold.md#retro-tapping) to be enabled, and
255if both are enabled the state of `retro tapping` will only apply if the tap keycode
256is not matched by Auto Shift. `RETRO_TAPPING_PER_KEY` and its corresponding
257function, however, are checked before `retro shift` is applied.
258
259To enable `retro shift`, add the following to your `config.h`:
260
261```c
262#define RETRO_SHIFT
263```
264
265If `RETRO_SHIFT` is defined to a value, hold times greater than that value will
266not produce a tap on release for Mod Taps, and instead triggers the hold action.
267This enables modifiers to be held for combining with mouse clicks without
268generating taps on release. For example:
269
270```c
271#define RETRO_SHIFT 500
272```
273
274This value (if set) must be greater than one's `TAPPING_TERM`, as the key press
275must be designated as a 'hold' by `process_tapping` before we send the modifier.
276There is no such limitation in regards to `AUTO_SHIFT_TIMEOUT` for normal keys.
277
278### Retro Shift and Tap Hold Configurations
279
280Tap Hold Configurations work a little differently when using Retro Shift.
281Referencing `TAPPING_TERM` makes little sense, as holding longer would result in
282shifting one of the keys.
283
284`IGNORE_MOD_TAP_INTERRUPT` changes *only* rolling from a mod tap (releasing it
285first), sending both keys instead of the modifier on the second. Its effects on
286nested presses are ignored.
287
288As nested taps were changed to act as though `PERMISSIVE_HOLD` is set unless only
289`IGNORE_MOD_TAP_INTERRUPT` is (outside of Retro Shift), and Retro Shift ignores
290`IGNORE_MOD_TAP_INTERRUPT`, `PERMISSIVE_HOLD` has no effect on Mod Taps.
291
292Nested taps will *always* act as though the `TAPPING_TERM` was exceeded for both
293Mod and Layer Tap keys.
294
147## Using Auto Shift Setup 295## Using Auto Shift Setup
148 296
149This will enable you to define three keys temporarily to increase, decrease and report your `AUTO_SHIFT_TIMEOUT`. 297This will enable you to define three keys temporarily to increase, decrease and report your `AUTO_SHIFT_TIMEOUT`.