Karabiner-Elements lets you remap keyboard keys at the system level on macOS, before any app sees them. Simple remappings (like Caps Lock → Escape for vim users) take seconds to set up. Complex modifications let you create layer-based shortcuts, dual-role keys, and application-specific rules.
A popular use case is the “hyper key” setup — remapping Caps Lock to simultaneously hold ⌃ ⌥ ⌘ ⇧ when held, and Escape when tapped. This gives you a clean modifier key for system-wide shortcuts that never conflicts with app shortcuts.
The community-maintained “Complex Modifications” rules library at ke-complex-modifications.pqrs.org has hundreds of ready-made rules you can import with one click.