Introduction
Welcome to map2
Want to remap your input devices like keyboards, mice, controllers and more?
There’s nothing you can’t remap with map2!
- 🖱️ Remap keys, mouse events, controllers, pedals, and more!
- 🔧 Highly configurable, using Python
- 🚀 Blazingly fast, written in Rust
- 📦 Tiny install size (around 5Mb), almost no dependencies
- ❤️ Open source, made with love
Let’s look at an example:
import map2
# readers intercept all keyboard inputs and forward them
reader = map2.Reader(patterns=["/dev/input/by-id/my-keyboard"])
# mappers change inputs, you can also chain multiple mappers!
mapper = map2.Mapper()
# writers create new virtual devices we can write into
writer = map2.Writer(clone_from = "/dev/input/by-id/my-keyboard")
# finally, link nodes to control the event flow
map2.link([reader, mapper, writer])
# map the "a" key to "B"
mapper.map("a", "B")
# map "CTRL + ALT + u" to "META + SHIFT + w"
mapper.map("^!u", "#+w")
# key sequences are also supported
mapper.map("s", "hello world!")
# use the full power of Python using functions
def custom_function(key, state):
print("called custom function")
# custom conditions and complex sequences
if key == "d":
return "{ctrl down}a{ctrl up}"
return True
mapper.map("d", custom_function)
For the next step, check the Install page and the Getting started page.