Skip to content

Map Down Arrow key to Shift Up Arrow key

An old laptop with missing cap on the down arrow key. So I would like to map the down arrow key to Shift-Up arrow. Tried with xmodmap...keycodes are 111 and 116. So I created an ~/.Xmodmap with keycode 111 (up arrow) to Up Down Up (which I thought meant press key, press Shift and key for the second one (instead of No-Symbol). Ran xmodmap and the change went in. But regardless of restarting X or rebooting, this had no effect on the up arrow key.

Can anyone tell me how to do this? Thanks.

8 points5 comments
Open on Reddit
About this post
Posted
Archived
Score
8 · 75% up
Kind
Text
ID
pvm48d

Author

16
posts
133
comments
0
media
View profile

5 comments

You're right about how xmodmap works, 1st is the default key and 2nd is key+shift.

I just tested it with xmodmap -e "keycode 111 = Up Down" and it partially worked. It shift+up sends a down, but since shift is still held programs interpret this as shift+down. I don't think xmodmap alone can do what you want.

3 points

Hard part is making it so that shif+up doesn't send shift... It might be worth investigating this program, though I'm not entirely sure it can do what you want (never used it)

2 points

I will take a look at Kmonad and see if it's for me. Thanks for the help.

1 points

This can be done using Xmodmap and the Mode_switch key.

I map my left Alt button to be the Mode_switch key, and have h, j, k, and l become Left, Down, Up, and Right when the Mode_switch key is held. I have the following in my ~/.Xmodmap file:

! bind Alt_L to Mode_switch
keycode 64 = Mode_switch

! bind vim style movement to Mode_switch slot
keysym h = h H Left
keysym j = j J Down
keysym k = k K Up
keysym l = l L Right

The first keysym h is used when no modifier key is pressed in conjunction with the key, the second H with Shift, and the third Left when the Mode_switch key is held.

For an answer close to how you described, first choose a key to bind to the Mode_switch key. The keycode of a key can be found using the xev program. Then bind the Up keys Mode_switch slot to send the Down key.

! bind Alt_L to Mode_switch
keycode 64 = Mode_switch

keysym Up = Up Up Down

Load the changes to the Xmodmap file using:

xmodmap ~/.Xmodmap
1 points

I think this is almost certainly what I was looking for. Thank you. I can't try it out just now (subject computer not available), but I will.

I am still curious as to why

keysym Up = Up Down

wouldn't work for Shift Up as a Down key, but your solution makes it a moot point.

Thanks again.

1 points

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.