import { _ as _export_sfc, c as createElementBlock, o as openBlock, a8 as createStaticVNode } from "./chunks/framework.B9AX-CPi.js"; const __pageData = JSON.parse('{"title":"Auto Shift: Why Do We Need a Shift Key?","description":"","frontmatter":{},"headers":[],"relativePath":"features/auto_shift.md","filePath":"features/auto_shift.md"}'); const _sfc_main = { name: "features/auto_shift.md" }; const _hoisted_1 = /* @__PURE__ */ createStaticVNode('
Tap a key and you get its character. Tap a key, but hold it slightly longer and you get its shifted state. Voilà! No shift key needed!
Many people suffer from various forms of RSI. A common cause is stretching your fingers repetitively long distances. For us on the keyboard, the pinky does that all too often when reaching for the shift key. Auto Shift looks to alleviate that problem.
When you tap a key, it stays depressed for a short period of time before it is then released. This depressed time is a different length for everyone. Auto Shift defines a constant AUTO_SHIFT_TIMEOUT
which is typically set to twice your normal pressed state time. When you press a key, a timer starts, and if you have not released the key after the AUTO_SHIFT_TIMEOUT
period, then a shifted version of the key is emitted. If the time is less than the AUTO_SHIFT_TIMEOUT
time, or you press another key, then the normal state is emitted.
If AUTO_SHIFT_REPEAT
is defined, there is keyrepeat support. Holding the key down will repeat the shifted key, though this can be disabled with AUTO_SHIFT_NO_AUTO_REPEAT
. If you want to repeat the normal key, then tap it once then immediately (within TAPPING_TERM
) hold it down again (this works with the shifted value as well if auto-repeat is disabled).
There are also the get_auto_shift_repeat
and get_auto_shift_no_auto_repeat
functions for more granular control. Neither will have an effect unless AUTO_SHIFT_REPEAT_PER_KEY
or AUTO_SHIFT_NO_AUTO_REPEAT_PER_KEY
respectively are defined.
Yes, unfortunately.
Add to your rules.mk
in the keymap folder:
AUTO_SHIFT_ENABLE = yes
If no rules.mk
exists, you can create one.
Then compile and install your new firmware with Auto Key enabled! That's it!
By default, Auto Shift is disabled for any key press that is accompanied by one or more modifiers. Thus, Ctrl+A that you hold for a really long time is not the same as Ctrl+Shift+A.
You can re-enable Auto Shift for modifiers by adding a define to your config.h
#define AUTO_SHIFT_MODIFIERS
In which case, Ctrl+A held past the AUTO_SHIFT_TIMEOUT
will be sent as Ctrl+Shift+A
If desired, there is some configuration that can be done to change the behavior of Auto Shift. This is done by setting various variables the config.h
file located in your keymap folder. If no config.h
file exists, you can create one.
A sample is
#pragma once\n\n#define AUTO_SHIFT_TIMEOUT 150\n#define NO_AUTO_SHIFT_SPECIAL
This controls how long you have to hold a key before you get the shifted state. Obviously, this is different for everyone. For the common person, a setting of 135 to 150 works great. However, one should start with a value of at least 175, which is the default value. Then work down from there. The idea is to have the shortest time required to get the shifted state without having false positives.
Play with this value until things are perfect. Many find that all will work well at a given value, but one or two keys will still emit the shifted state on occasion. This is simply due to habit and holding some keys a little longer than others. Once you find this value, work on tapping your problem keys a little quicker than normal and you will be set.
TIP
Auto Shift has three special keys that can help you get this value right very quick. See "Auto Shift Setup" for more details!
For more granular control of this feature, you can add the following to your config.h
:
#define AUTO_SHIFT_TIMEOUT_PER_KEY
You can then add the following function to your keymap:
uint16_t get_autoshift_timeout(uint16_t keycode, keyrecord_t *record) {\n switch(keycode) {\n case AUTO_SHIFT_NUMERIC:\n return 2 * get_generic_autoshift_timeout();\n case AUTO_SHIFT_SPECIAL:\n return get_generic_autoshift_timeout() + 50;\n case AUTO_SHIFT_ALPHA:\n default:\n return get_generic_autoshift_timeout();\n }\n}
Note that you cannot override individual keys that are in one of those groups if you are using them; trying to add a case for KC_A
in the above example will not compile as AUTO_SHIFT_ALPHA
is there. A possible solution is a second switch above to handle individual keys with no default case and only referencing the groups in the below fallback switch.
Do not Auto Shift special keys, which include -_, =+, [{, ]}, ;:, '", ,<, .>, /?, and the KC_TAB.
Do not Auto Shift KC_TAB but leave Auto Shift enabled for the other special characters.
Do not Auto Shift symbol keys, which include -_, =+, [{, ]}, ;:, '", ,<, .>, and /?.
Do not Auto Shift numeric keys, zero through nine.
Do not Auto Shift alpha characters, which include A through Z.
Auto Shift the enter key.
There are functions that allows you to determine which keys should be autoshifted, much like the tap-hold keys.
The first of these, used to simply add a key to Auto Shift, is get_custom_auto_shifted_key
:
bool get_custom_auto_shifted_key(uint16_t keycode, keyrecord_t *record) {\n switch(keycode) {\n case KC_DOT:\n return true;\n default:\n return false;\n }\n}
For more granular control, there is get_auto_shifted_key
. The default function looks like this:
bool get_auto_shifted_key(uint16_t keycode, keyrecord_t *record) {\n switch (keycode) {\n# ifndef NO_AUTO_SHIFT_ALPHA\n case AUTO_SHIFT_ALPHA:\n# endif\n# ifndef NO_AUTO_SHIFT_NUMERIC\n case AUTO_SHIFT_NUMERIC:\n# endif\n# ifndef NO_AUTO_SHIFT_SPECIAL\n# ifndef NO_AUTO_SHIFT_TAB\n case KC_TAB:\n# endif\n# ifndef NO_AUTO_SHIFT_SYMBOLS\n case AUTO_SHIFT_SYMBOLS:\n# endif\n# endif\n# ifdef AUTO_SHIFT_ENTER\n case KC_ENT:\n# endif\n return true;\n }\n return get_custom_auto_shifted_key(keycode, record);\n}
This functionality is enabled by default, and does not need a define.
Enables keyrepeat.
Disables automatically keyrepeating when AUTO_SHIFT_TIMEOUT
is exceeded.
A predefined group of keys representing A through Z.
A predefined group of keys representing 0 through 9. Note, these are defined as 1 through 0 since that is the order they normally appear in.
A predefined group of keys representing symbolic characters which include -_, =+, [{, ]}, ;:, '", ,<, .>, and /?.
A predefined group of keys that combines AUTO_SHIFT_SYMBOLS and KC_TAB.
Especially on small keyboards, the default shifted value for many keys is not optimal. To provide more customizability, there are two user-definable functions, autoshift_press/release_user
. These register or unregister the correct value for the passed key. Below is an example adding period to Auto Shift and making its shifted value exclamation point. Make sure to use weak mods - setting real would make any keys following it use their shifted values as if you were holding the key. Clearing of modifiers is handled by Auto Shift, and the OS-sent shift value if keyrepeating multiple keys is always that of the last key pressed (whether or not it's an Auto Shift key).
You can also have non-shifted keys for the shifted values (or even no shifted value), just don't set a shift modifier!
bool get_custom_auto_shifted_key(uint16_t keycode, keyrecord_t *record) {\n switch(keycode) {\n case KC_DOT:\n return true;\n default:\n return false;\n }\n}\n\nvoid autoshift_press_user(uint16_t keycode, bool shifted, keyrecord_t *record) {\n switch(keycode) {\n case KC_DOT:\n register_code16((!shifted) ? KC_DOT : KC_EXLM);\n break;\n default:\n if (shifted) {\n add_weak_mods(MOD_BIT(KC_LSFT));\n }\n // & 0xFF gets the Tap key for Tap Holds, required when using Retro Shift\n register_code16((IS_RETRO(keycode)) ? keycode & 0xFF : keycode);\n }\n}\n\nvoid autoshift_release_user(uint16_t keycode, bool shifted, keyrecord_t *record) {\n switch(keycode) {\n case KC_DOT:\n unregister_code16((!shifted) ? KC_DOT : KC_EXLM);\n break;\n default:\n // & 0xFF gets the Tap key for Tap Holds, required when using Retro Shift\n // The IS_RETRO check isn't really necessary here, always using\n // keycode & 0xFF would be fine.\n unregister_code16((IS_RETRO(keycode)) ? keycode & 0xFF : keycode);\n }\n}
Holding and releasing a Tap Hold key without pressing another key will ordinarily result in only the hold. With retro shift
enabled this action will instead produce a shifted version of the tap keycode on release.
It does not require Retro Tapping to be enabled, and if both are enabled the state of retro tapping
will only apply if the tap keycode is not matched by Auto Shift. RETRO_TAPPING_PER_KEY
and its corresponding function, however, are checked before retro shift
is applied.
To enable retro shift
, add the following to your config.h
:
#define RETRO_SHIFT
If RETRO_SHIFT
is defined to a value, hold times greater than that value will not produce a tap on release for Mod Taps, and instead triggers the hold action. This enables modifiers to be held for combining with mouse clicks without generating taps on release. For example:
#define RETRO_SHIFT 500
Without a value set, holds of any length without an interrupting key will produce the shifted value.
This value (if set) must be greater than one's TAPPING_TERM
, as the key press must be designated as a 'hold' by process_tapping
before we send the modifier. Per-key tapping terms can be used as a workaround. There is no such limitation in regards to AUTO_SHIFT_TIMEOUT
for normal keys.
Note: Tap Holds must be added to Auto Shift, see here.IS_RETRO
may be helpful if one wants all Tap Holds retro shifted.
Tap Hold Configurations work a little differently when using Retro Shift. Referencing TAPPING_TERM
makes little sense, as holding longer would result in shifting one of the keys.
RETRO_SHIFT
enables PERMISSIVE_HOLD
-like behaviour (even if not explicitly enabled) on all mod-taps for which RETRO_SHIFT
applies.
This will enable you to define three keys temporarily to increase, decrease and report your AUTO_SHIFT_TIMEOUT
.
Map three keys temporarily in your keymap:
Keycode | Aliases | Description |
---|---|---|
QK_AUTO_SHIFT_DOWN | AS_DOWN | Lower the Auto Shift timeout variable (down) |
QK_AUTO_SHIFT_UP | AS_UP | Raise the Auto Shift timeout variable (up) |
QK_AUTO_SHIFT_REPORT | AS_RPT | Report your current Auto Shift timeout value |
QK_AUTO_SHIFT_ON | AS_ON | Turns on the Auto Shift Function |
QK_AUTO_SHIFT_OFF | AS_OFF | Turns off the Auto Shift Function |
QK_AUTO_SHIFT_TOGGLE | AS_TOGG | Toggles the state of the Auto Shift feature |
Compile and upload your new firmware.
It is important to note that during these tests, you should be typing completely normal and with no intention of shifted keys.
AS_DOWN
to decrease time Auto Shift timeout value and go back to step 1.AS_UP
and go back to step 1.AS_RPT
. The keyboard will type by itself the value of your AUTO_SHIFT_TIMEOUT
.AUTO_SHIFT_TIMEOUT
in your config.h
with the value reported.AUTO_SHIFT_NO_SETUP
to your config.h
.AS_DOWN
, AS_UP
and AS_RPT
.hello world. my name is john doe. i am a computer programmer playing with\nkeyboards right now.\n\n[PRESS AS_DOWN quite a few times]\n\nheLLo woRLd. mY nAMe is JOHn dOE. i AM A compUTeR proGRaMMER PlAYiNG witH\nKEYboArDS RiGHT NOw.\n\n[PRESS AS_UP a few times]\n\nhello world. my name is john Doe. i am a computer programmer playing with\nkeyboarDs right now.\n\n[PRESS AS_RPT]\n\n115
The keyboard typed 115
which represents your current AUTO_SHIFT_TIMEOUT
value. You are now set! Practice on the D key a little bit that showed up in the testing and you'll be golden.