Remapping Caps Lock to "menu"

Kernels & Hardware, configuring network, installing services

Remapping Caps Lock to "menu"

Postby kriukov » 2017-08-16 00:14

I've been trying to remap Caps Lock to "menu" key (the one that does the same as the right click of the mouse). I tried various options I found, such as setxkbmap -option "caps:menu", putting "caps:menu" to XKBOPTIONS in /etc/default/keyboard and other, but none worked. I use MATE 1.8.1 on Debian Jessie and keep Caps Lock currently disabled via mate-keyboard-properties. Does anyone know how this could be done?
kriukov
 
Posts: 5
Joined: 2017-01-19 07:08
Location: Mexico City

Re: Remapping Caps Lock to "menu"

Postby shep » 2017-08-16 01:22

Normally, you can extract a keycode by using "xev". This opens a terminal window that displays the keycode for any key that is subsequently hit.
Code: Select all
Caps Lock.  On my system"KeyPress event, serial 48, synthetic NO, window 0x2800001,
    root 0x4a2, subw 0x0, time 40431001, (445,-328), root:(447,130),
    state 0x0, keycode 66 (keysym 0xffe5, Caps_Lock), same_screen YES,
    XLookupString gives 0 bytes:
    XmbLookupString gives 0 bytes:
    XFilterEvent returns: False

KeyRelease event, serial 48, synthetic NO, window 0x2800001,
    root 0x4a2, subw 0x0, time 40431101, (445,-328), root:(447,130),
    state 0x2, keycode 66 (keysym 0xffe5, Caps_Lock), same_screen YES,
    XLookupString gives 0 bytes:
    XFilterEvent returns: False

KeyPress event, serial 48, synthetic NO, window 0x2800001,
    root 0x4a2, subw 0x0, time 40444864, (0,-172), root:(2,286),
    state 0x2, keycode 66 (keysym 0xffe5, Caps_Lock), same_screen YES,
    XLookupString gives 0 bytes:
    XmbLookupString gives 0 bytes:
    XFilterEvent returns: False

KeyRelease event, serial 48, synthetic NO, window 0x2800001,
    root 0x4a2, subw 0x0, time 40444956, (0,-172), root:(2,286),
    state 0x2, keycode 66 (keysym 0xffe5, Caps_Lock), same_screen YES,
    XLookupString gives 0 bytes:
    XFilterEvent returns: False


Ths issue your are going to have is that this key Truely Locks/Unlocks. If you Caps Lock and bring up a menu and then make a menu selection, you will should get another menu when you unlock in order to enter lower case characters.

I would recommend a key combination. Also, by default, the lefthand "Windows" key, between CTL and ALT is the default Menu key for many desktops and Firefox. It is typically the Super_L key. I switched my menu in OpenBox from [Super_L] to [CTL + ALt + m] to avoid a conflict when the browser was open.
Code: Select all
KeyRelease event, serial 48, synthetic NO, window 0x2600001,
    root 0x4a2, subw 0x0, time 40931246, (1064,350), root:(1066,415),
    state 0x40, keycode 115 (keysym 0xffeb, Super_L), same_screen YES,
    XLookupString gives 0 bytes:
    XFilterEvent returns: False

See this howto for examples to bind keys in Mate.
Last edited by shep on 2017-08-16 01:37, edited 3 times in total.
shep
 
Posts: 130
Joined: 2011-03-15 15:22

Re: Remapping Caps Lock to "menu"

Postby Bulkley » 2017-08-16 01:30

Why not just right click the mouse?

The CapsLock button is a real pain in the neck to me because fat-fingering a keyboard means having to undo a lot of capitals. I reprogrammed mine to do nothing; it's dead. I put the following into ~/.config/openbox/autostart.sh
Code: Select all
setxkbmap -option caps:none


Look up setxkbmap and xkbcomp. You may have to write a little script.
Last edited by Bulkley on 2017-08-16 15:43, edited 1 time in total.
Bulkley
 
Posts: 5326
Joined: 2006-02-11 18:35

Re: Remapping Caps Lock to "menu"

Postby kriukov » 2017-08-16 07:53

I already use the WIndows key for some options (such as Win+L to lock the screen, Win+E to invoke the file browser etc). As to why not right-click the mouse: 1) When I am using only the keyboard, having to touch the mouse for one single operation is inconvenient; 2) my keyboard doesn't have the Menu key but has the useless Caps Lock key, and giving it this functionality seems like the most obvious choice; and 3) on my previous Linux system that I used before Jessie, Ubuntu 10.04 Lucid Lynx, I did this and it worked, I just don't remember how I did it.
kriukov
 
Posts: 5
Joined: 2017-01-19 07:08
Location: Mexico City

Re: Remapping Caps Lock to "menu"

Postby debiman » 2017-08-16 15:28

i don't know how to do it, but i do know that it has been done.
please have a look.
User avatar
debiman
 
Posts: 1545
Joined: 2013-03-12 07:18

Re: Remapping Caps Lock to "menu"

Postby Bulkley » 2017-08-16 15:42

In a terminal if I want to bring up my Openbox menu I have to enter obmenu. kriukov is using Mate which must have a similar instruction. What he needs is for the CapsLock button to run an instruction which brings up the Mate menu. It's an intriguing problem.
Bulkley
 
Posts: 5326
Joined: 2006-02-11 18:35

Re: Remapping Caps Lock to "menu"

Postby Bulkley » 2017-08-16 16:12

kriukov, look at /usr/share/X11/xkb/rules/base.lst. If you scroll down you should find
Code: Select all
caps:menu            Make Caps Lock an additional Menu key
It seems to me that you should be able to do something like
Code: Select all
setxkbmap -option caps:menu
Bulkley
 
Posts: 5326
Joined: 2006-02-11 18:35

Re: Remapping Caps Lock to "menu"

Postby shep » 2017-08-16 18:21

The original post stated that he was using Mate 1.8.1 and I gave a link about mapping keys to menus specifically for Mate at the end of an earlier post. My post may have been too lengthy. I'm getting the sense that anything exceeding a 140 character attention span is a waste of bandwidth.
shep
 
Posts: 130
Joined: 2011-03-15 15:22

Re: Remapping Caps Lock to "menu"

Postby thunderogg » 2017-08-16 21:18

I did it in /etc/default/keyboard.
Code: Select all
XKBOPTIONS="caps:menu"

Works fine for xfce4.
Debian 9 / Xfce4
thunderogg
 
Posts: 198
Joined: 2008-12-10 20:12

Re: Remapping Caps Lock to "menu"

Postby kriukov » 2017-08-17 00:45

Thanks to all. In /usr/share/X11/xkb/rules/base.lst, there was no caps:menu, and when I added it, nothing happened (I thought it would appear as an option in mate-keyboard-properties, but no. I tried to follow this page to modify .Xmodmap, but this didn't work either. From the same file and xev I found out that it is key 66 and its name is not Caps_Lock, but Mode_switch (lowercase "s"). The only case when it finally worked is when I removed "Mode_switch" and put "Menu" there, and executed xmodmap ~/.Xmodmap (which I then tried to put to .xinitrc (crashed X), to .bash_profile (did nothing) and, finally, to "Startup Applications" (mate-session-properties), which worked after logout/restart). So I think it works now.
kriukov
 
Posts: 5
Joined: 2017-01-19 07:08
Location: Mexico City

Re: Remapping Caps Lock to "menu"

Postby thunderogg » 2017-08-17 10:58

Debian 9 / Xfce4
thunderogg
 
Posts: 198
Joined: 2008-12-10 20:12

Re: Remapping Caps Lock to "menu"

Postby debiman » 2017-08-17 15:01

Bulkley wrote:It seems to me that you should be able to do something like
Code: Select all
setxkbmap -option caps:menu

holy crap, that actually works!
now how do i get rid of it...
User avatar
debiman
 
Posts: 1545
Joined: 2013-03-12 07:18

Re: Remapping Caps Lock to "menu"

Postby Gaius » 2017-09-10 21:34

Hmmm, it seems that at times there are distinct advantages, using a resource-intensive DE ...

Image
Keyboard Mapping Options / KDE 5.8.6

Image
Options for the CapsLock Key

Of course it's more manly to use the command line, I realise that ..... :D

Cheers,
Gaius
If you can’t explain it simply, you don’t understand it well enough.
Albert Einstein
User avatar
Gaius
 
Posts: 33
Joined: 2012-12-18 10:54
Location: Germany


Return to System configuration

Who is online

Users browsing this forum: No registered users and 8 guests

fashionable