diff --git a/src/api/focus/keymap/db/constants.js b/src/api/focus/keymap/db/constants.js
index dd9fed62d..9961fed93 100644
--- a/src/api/focus/keymap/db/constants.js
+++ b/src/api/focus/keymap/db/constants.js
@@ -69,6 +69,12 @@ const keycode_ranges = {
turbo: { start: 0xd15b, end: 0xd15b },
};
export const constants = {
+ limits: {
+ // Using a secondary action for layer shifts is limited to 8 layers due to
+ // technical reasons in Kaleidoscope. We overflow the key range assigned to
+ // secondary actions if we got beyond layer 7. (Layer 0 is the first layer.)
+ secondaryActionLayerLimit: 7,
+ },
codes: {
// Keycodes
ESCAPE: 41,
diff --git a/src/renderer/screens/Editor/Sidebar/LayerKeys.js b/src/renderer/screens/Editor/Sidebar/LayerKeys.js
index e9655c319..f5ff190df 100644
--- a/src/renderer/screens/Editor/Sidebar/LayerKeys.js
+++ b/src/renderer/screens/Editor/Sidebar/LayerKeys.js
@@ -48,8 +48,8 @@ const LayerKeys = (props) => {
if (db.isInCategory(key.code, "layer") && key.categories.includes("dualuse")) {
const code = key.baseCode || key.code;
- if (target < 0) target = getMaxLayer();
- if (target > getMaxLayer()) target = 0;
+ if (target < 0) target = db.constants.limits.secondaryActionLayerLimit;
+ if (target > db.constants.limits.secondaryActionLayerLimit) target = 0;
props.onKeyChange(addDualUseLayer(db.lookup(code), target).code);
} else {
@@ -120,7 +120,7 @@ const LayerKeys = (props) => {
>
{[...Array(getMaxLayer())].map((x, i) => (
-