marketplace/remapping

Hyper Caps Lock

v0.1.0

@rebindfree

Caps Lock acts as Ctrl when held and Escape when tapped.

Gallery

Hyper Caps Lock preview

Readme

Hold Caps Lock for Ctrl, right under your little finger. Tap it on its own for Escape.

Needs Rebind 3.5.0 or newer on Windows or Linux. No extra permissions.

Settings

  • Key to change: default Caps Lock.
  • Held, it acts as: default Left Ctrl.
  • Tapped alone, it sends: default Escape.
  • A tap is shorter than: a press shorter than this, with no other key, counts as a tap. 100 to 400 ms, default 180.

Key changes apply while the package runs on Rebind 3.9 or newer. On older versions, restart the package.

Limits

  • macOS is not supported yet: Caps Lock reaches Rebind there as a switch, not a held key, so it cannot act as Ctrl.
  • Caps Lock no longer toggles caps while the package runs.
  • Live use remains unverified on Windows and Linux.

Stop

Stopping the package releases Ctrl. Stop it from the editor toolbar, or press Left Ctrl + Left Alt + K to stop all scripts.

Reviews

No reviews yet. Be the first, from the app.

Source

Version 0.1.0 (current)

main.luau

-- Hyper Caps Lock: hold the source key and it acts as Ctrl; tap it on its own
-- and it sends Escape.

local cfg = UI.Schema({
  source = UI.Keybind("CapsLock", { label = "Key to change" }),
  holdAs = UI.Keybind("LCtrl", { label = "Held, it acts as" }),
  tapAs = UI.Keybind("Escape", { label = "Tapped alone, it sends" }),
  tapMs = UI.Slider(180, {
    min = 100,
    max = 400,
    suffix = " ms",
    label = "A tap is shorter than",
  }),
})

local down, used = false, false

function OnDown(key)
  if key == cfg.source then
    if not down then
      down, used = true, false
      HID.Down(cfg.holdAs)
    end
    return false
  end
  if down then
    used = true
  end
  return true
end

function OnUp(key, durationMs)
  if key ~= cfg.source then
    return true
  end
  if not down then
    return false
  end
  HID.Up(cfg.holdAs)
  if not used and (durationMs or 0) < cfg.tapMs then
    HID.Combo(cfg.tapAs)
  end
  down = false
  return false
end

function OnStop()
  if down then
    HID.Up(cfg.holdAs)
  end
end