05-03-26

Remap CapsLock to Escape Key

This Lua script remaps the CapsLock key to the Escape key using hardware input. It's useful for users who want to change their keybindings. This script uses the Rebind platform.

rebindlua scriptcapslockescapekey remappinghardware inputremap

Question

Capslock to escape key remap

Rebind AI

luau
-- rebind: name=CapsLock to Escape

function OnDown(key)
    if key == "CapsLock" then
        HID.Press("Escape")
        return false
    end
    return true
end

function OnUp(key)
    if key == "CapsLock" then
        return false
    end
    return true
end

How it works:

When CapsLock is pressed, this script sends an Escape key instead and blocks the original CapsLock from reaching your PC (return false). When CapsLock is released, it also blocks that event to prevent any CapsLock behavior.

This is a global script with no targeting, so it works everywhere — in all applications.

Learn more