alols / xcape

Linux utility to configure modifier keys to act as other keys when pressed and released on their own.
GNU General Public License v3.0
2.1k stars 115 forks source link

Successfully using space bar as a modifier question #81

Open divansantana opened 7 years ago

divansantana commented 7 years ago

More of a question. xcape is awesome, btw - thanks!

So man xcape says.

As an example, we can make the space bar work as an additional ctrl key when held with the following sequence of commands:

I've used xcape and xmodmap to make space key act as mod4/Super_L. It's easier to push space bar then the "windows" key. I use i3 so this is pretty helpful too.

It's a nice change. But I find it really difficult to keep this change because now a space character is only inserted when the spacebar is fully released. When one types quickly I often land up with no spaces separated words and other similar issues.

I guess I'm wondering feedback on other users experience with mapping the spacebar as a modifier. Did you manage to it successfully and how?

divansantana commented 7 years ago

For me, I can't use modify the spacebar successfully and adapt to the new way it works without it interfering a lot. A better fix for me is to modify another "normal" key like ; to work as mod4.

Only issue there is I haven't figured out how to do that with xcape. When I do this I can't get the shift+; to generate a colon.

xiongtx commented 7 years ago

I've had the same experience.

The fundamental problem is that we are used to the space being inserted at key press, not release. Fast typist like us don't wait for the space bar to be released before hitting the next key.

Trying to use space bar as a modifier key, however, requires that it is treated as Control until release. There's no way, even in theory, to get around this.

divansantana commented 7 years ago

@xiongtx Yes. For now I've mostly adapted to the issue. Using space for me has greatly helped with RSI. There's no way to resolve the issue. But is nice to share experiences etc.

Perhaps one could use another less used key like , instead of space, which is still easily in reach.

diego-alvarez-hs commented 7 years ago

:disappointed: I couldn't adapt to this workflow, I kept hitting other keys without space being released

amosbird commented 7 years ago

I use a japanese keyboard to overcome this.

CNG commented 5 years ago

I'm also working on adapting to this. It's been a bit frustrating when I was accidentally triggering various i3 commands during my typing, but it seems to be less frequent now. Perhaps I'm also "helped" by my typing being much slower lately since switching to Dvorak.

I'm also experiencing the need to kill and restart xcape every time I plug or unplug a monitor; I am still tracking down this problem. Edit: I think I solved this problem by fixing an issue with my config. I had xcape starting in ~/.xprofile, which, on my system, is sourced in /etc/lightdm/Xsession earlier than xmodmap runs. I moved this to ~/.xsession, which is sourced last in that file, and it seems to have helped... but I also added sourcing xsession to my i3 config. I am leaning toward i3 was reloading on monitor change as the issue, and something key related was running and overwriting xcape and xmodmap settings. Still need to debug further.

CNG commented 5 years ago

I'm now trying to stop using space as a modifier, as it's gotten too annoying to be accidentally launching programs and moving windows while typing and sharing my screen during meetings. Perhaps if there were a time threshold where xcape would change the spacebar to a modifier key only after it's been held down for some amount of time, that could solve this issue.

divansantana commented 5 years ago

My crazy setup. Which works well for me.

Caps is mod4/windows/super key. Easier to reach then the default mod4 place and used for my desktop (EXWM) shortcuts.

space bar is space and CTRL. I can't recall when last I hit the space bar/CTRL key and didn't get what I expected. It took a few weeks to adapt.

Mostly forced due to RSI issues.

setxkbmap -layout dvorak

pkill -9 -f xcape

# Make typematic keyboard delay and rate faster.
# default is 660ms and 25Hz
xset r rate 180 120

# defaults
# keycode 133 (keysym 0xffeb, Super_L) left window key
# keycode 65 (keysym 0x20, space) space
# keycode 66 (keysym 0xffe5, Caps_Lock)
# keycode 37 (keysym 0xffe3, Control_L)
# keycode 105 (keysym 0xffe4, Control_R)
# keycode 36 (keysym 0xff0d, Return)
# keycode 47 (keysym 0x3b, semicolon)
# keycode 9 (keysym 0xff1b, Escape)
# keycode 108 (keysym 0xffea, Alt_R)
# keycode 64 (keysym 0xffe9, Alt_L)

xmodmap -e "clear lock"
xmodmap -e "keycode 66 = Super_L"
xmodmap -e "keycode 36 = Super_R"

spare_modifier="Hyper_L"
xmodmap -e "keycode 65 = $spare_modifier"
xmodmap -e "remove mod4 = $spare_modifier"
xmodmap -e "add Control = $spare_modifier"

xmodmap -e "keycode any = space"
xmodmap -e "keycode any = Return"

xcape -t 1000 -e "Shift_L=Escape;Shift_R=Escape;Super_R=Return;$spare_modifier=space"

notify-send -t 5000 "Keyboard settings applied."
forgetmenotz commented 4 years ago

nevermind

forgetmenotz commented 4 years ago

@divansantana

Interesting that you got used to it. Do you think you could use it if it was something other than control? I would be surprised if you didn't get capital letters if the space was xcaped to shift rather than control. Do you type slower consciously now? I'm tempted to try this again for a weeks now.

danr commented 4 years ago

Are you on traditional laptop keyboards? I have to use an "ergonomic" keyboard like the kinesis advantage. These give a lot of keys on the thumbs, and I use xcape on backspace and delete (which are thumb keys) for ctrl and alt. RSI kicks in on laptop keyboards after just a day of use or so.

divansantana commented 4 years ago

@forgetmenotz I'm getting about 70wpm with virtually no mistakes. I did learn to type from scratch again and that helped because I was typing slower and did have to adjust to the space thing.

I also noticed I only use my right thumb to press the space bar, which is not ideal but works.

divansantana commented 4 years ago

I mostly type on an ergodox, but I do type on a laptop dell keyboard often and havent't noticed any issues.

forgetmenotz commented 4 years ago

I had an idea that I thought might be able to solve this issue for those of us who hit the space modifier too often. If an xcape modifier could be set to disabled until a certain time after other keys are pressed, say some amount of milliseconds, it might prevent the unwanted modified keys while typing, but remain useful when not typing. Anyone think it could work? I'm not sure.

forgetmenotz commented 4 years ago

I've been using this for a few weeks now. In favour of the increased functionality of having space as altgr, I've kind of accepted the slower typing speed, which unfortunately has not gone away, and I still make mistakes here and there.

jirassimok commented 4 years ago

Trying to use space bar as a modifier key, however, requires that it is treated as Control until release. There's no way, even in theory, to get around this.

There is a way around this, but not with xcape, or any other tool that I am aware of for Linux. The solution is using different behaviors depending on whether the other keys are pressed and released while holding the space bar.

The sequence space down, X down, X up, space up, should act like pressing modifier+X, while space down, X down, space up, X up should act like space modifier.

This mapping still reduces typing speed, but it is much easier to learn than if both sequences turn space into a modifier, and much less prone to errors.

MaxGyver83 commented 4 years ago

There is a way around this, but not with xcape, or any other tool that I am aware of for Linux.

KMonad can do that. Search the tutorial for tap-next-release.