houmain / keymapper

A cross-platform context-aware key remapper.
GNU General Public License v3.0
298 stars 25 forks source link

Remapping `CapsLock` issues #16

Closed mark2185 closed 2 years ago

mark2185 commented 2 years ago

Hey!

Loving the tool so far, I just have a few questions regarding remapping CapsLock, I sometimes manage to toggle it when in actuality I don't ever want to have CapsLock turned on.

I want to have CapsLock+{hjkl} to work as arrow keys and that works as expected. I also want to have CapsLock by itself to act as Escape, and that part works as well. But I realised I sometimes press Backspace while holding CapsLock and that triggers it.

This solves it

CapsLock{Backspace}          >> Backspace
CapsLock{Control{Backspace}} >> Control{Backspace}
CapsLock                     >> Escape

...but I am curious as to why this doesn't work as expected.

CapsLock{Any}                >> Any
CapsLock                     >> Escape

I thought this was only supposed to pass through the keys, but it also toggles CapsLock, and only on the first press of the CapsLock+<any key> combo. It then stays enabled until I press CapsLock+<any key> again.

Am I missing something or is this a bug?

I'm on arch and Xorg btw.

mark2185 commented 2 years ago

Also, when running gscreenshot (link) the CapsLock stops working as Escape while I'm selecting a part of the screen to take the screenshot.

houmain commented 2 years ago

Thanks for reporting this issue. Hitting CapsLock{A} with this simple configuration toggles CapsLock, which is indeed not what one would immediately expect:

    CapsLock{Backspace} >> Backspace
    CapsLock            >> Escape

I will try to fix it.

p.s. I tried gscreenshot, but with this configuration cancelling with CapsLock worked for me...

mark2185 commented 2 years ago

I will try to fix it.

Great! Thanks!

p.s. I tried gscreenshot, but with this configuration cancelling with CapsLock worked for me...

It may be due to me mucking around with multiple layouts using setxkbmap... I also want to have a layout alongside the us one, and change them with e.g. win+space. To that end I had this before I discovered keymapper:

setxkbmap -layout us,hr
setxkbmap -option 'grp:win_space_toggle'

With my current config, I can't seem to cancel gscreenshot with CapsLock, although it isn't really an issue, any other keypress cancels it as well.

houmain commented 2 years ago

Hi, with 7c092b1160cff4862fda000d4435b5ec3bd3645a and your configuration CapsLock should never get turned on! Please try out keymapper-git from the AUR, I have not bumped the version yet.

mark2185 commented 2 years ago

I'm still managing to toggle capslock.

This is my config.

CapsLock{H} >> ArrowLeft
CapsLock{J} >> ArrowDown
CapsLock{K} >> ArrowUp
CapsLock{L} >> ArrowRight

CapsLock{Space}              >> Enter
CapsLock{E}                  >> Control{Tab}
CapsLock{Q}                  >> Control{Shift{Tab}}
CapsLock{X}                  >> Backspace
CapsLock{D}                  >> Control{Backspace}
CapsLock{B}                  >> Control{B}
CapsLock{Backspace}          >> Backspace
CapsLock{Control{Backspace}} >> Control{Backspace}
CapsLock{Any}                >> Control{Any}
CapsLock                     >> Escape

I press CapsLock{P} and it passes through Ctrl{P}, but toggles CapsLock.

And yes, I have reinstalled the package, and the correct hash is being checked out.

mark2185 commented 2 years ago

This is also a tad odd

CapsLock{H} >> ArrowLeft
CapsLock{J} >> ArrowDown
CapsLock{K} >> ArrowUp
CapsLock{L} >> ArrowRight

CapsLock{Space}              >> Enter

# TODO: this only for brave and guake
[class="brave-browser"]
CapsLock{E}                  >> Control{Tab}
CapsLock{Q}                  >> Control{Shift{Tab}}

Control{Tab}                 >>
Control{Shift{Tab}}          >>

ArrowLeft  >>
ArrowDown  >>
ArrowUp    >>
ArrowRight >>

CapsLock{X}                  >> Backspace
CapsLock{D}                  >> Control{Backspace}
CapsLock{B}                  >> Control{B}
CapsLock{Backspace}          >> Backspace
CapsLock{Control{Backspace}} >> Control{Backspace}
CapsLock{Any}                >> Control{Any}
CapsLock                     >> Escape

This works as expected in brave-browser, but in any other window pressing only CapsLock toggles it, while other explicit mappings work, e.g. CapsLock{K}.

EDIT: sorry, I misread the instructions They continue until the next block (respectively the end of the file):

I thought it was "respectively the end of the line" and found it odd, but continued on my way.

mark2185 commented 2 years ago

Hi, with 7c092b1 and your configuration CapsLock should never get turned on! Please try out keymapper-git from the AUR, I have not bumped the version yet.

I'm still managing to toggle capslock.

You know what, all the issues after this might have been due to me not restarting the keymapperd service.

I'll test it out in the next few days and will close this issue accordingly!

mark2185 commented 2 years ago

I can still toggle CapsLock.

This config passes through e.g. Control+C, but it also toggles CapsLock.

CapsLock{Any} >> Control{Any}
houmain commented 2 years ago

Yes, this is how Any in outputs currently works. It is replaced with the input sequence (which is CapsLock+C). This should work as intended: CapsLock{Any} >> !CapsLock Control{Any}

But I will think about improving the behavior of Any.

mark2185 commented 2 years ago

Yes, this is how Any in outputs currently works. It is replaced with the input sequence (which is CapsLock+C)

Oh, I thought it was just a pass-through.

This should work as intended: CapsLock{Any} >> !CapsLock Control{Any}

Indeed it does. Thanks for the debugging and the solution, I appreciate it!

I consider this "issue" to be solved, feel free to close it.