I don't think you need to swap `q` out of the keymap. Why not just special case it inside `handleKey`? i.e. if you are in macro mode, and you press `q`, end the macro recording directly in `handleKey`.