Created
October 13, 2020 12:21
-
-
Save vkz/2bf2c9ff60ea6676a0a686c954b0107f to your computer and use it in GitHub Desktop.
Dual key behavior with xcape: modifier or keypress
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Space is Shift modifier when pressed with any other key, usual SPACE otherwise | |
# https://github.com/alols/xcape | |
# only works in X | |
# Map an unused modifier's keysym to the spacebar's keycode and make it a | |
# control modifier. It needs to be an existing key so that emacs won't | |
# spazz out when you press it. Hyper_L is a good candidate. | |
spare="Hyper_L" | |
xmodmap -e "keycode 65 = $spare" | |
xmodmap -e "remove mod4 = $spare" # hyper_l is mod4 by default | |
xmodmap -e "add Shift = $spare" | |
# Map space to an unused keycode (to keep it around for xcape to | |
# use). | |
xmodmap -e "keycode any = space" | |
# Finally use xcape to cause the space bar to generate a space when tapped. | |
xcape -e "$spare=space" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Proper way to do it that works both in X and console would probably require https://gitlab.com/interception/linux/plugins/dual-function-keys
From what I gather it should be possible to achieve the same with just XKB which maybe arcane but appears very flexible. It is however underdocumented (I'm being generous here). Crude notes from when I attempted that and failed: