Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Remapping Caps Lock to "menu"

Linux Kernel, Network, and Services configuration.
Post Reply
Message
Author
kriukov
Posts: 11
Joined: 2017-01-19 07:08
Location: Mexico City

Remapping Caps Lock to "menu"

#1 Post by kriukov »

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?

shep
Posts: 423
Joined: 2011-03-15 15:22

Re: Remapping Caps Lock to "menu"

#2 Post by shep »

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.

Bulkley
Posts: 6383
Joined: 2006-02-11 18:35
Has thanked: 2 times
Been thanked: 39 times

Re: Remapping Caps Lock to "menu"

#3 Post by Bulkley »

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.

kriukov
Posts: 11
Joined: 2017-01-19 07:08
Location: Mexico City

Re: Remapping Caps Lock to "menu"

#4 Post by kriukov »

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.

User avatar
debiman
Posts: 3063
Joined: 2013-03-12 07:18

Re: Remapping Caps Lock to "menu"

#5 Post by debiman »

i don't know how to do it, but i do know that it has been done.
please have a look.

Bulkley
Posts: 6383
Joined: 2006-02-11 18:35
Has thanked: 2 times
Been thanked: 39 times

Re: Remapping Caps Lock to "menu"

#6 Post by Bulkley »

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: 6383
Joined: 2006-02-11 18:35
Has thanked: 2 times
Been thanked: 39 times

Re: Remapping Caps Lock to "menu"

#7 Post by Bulkley »

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

shep
Posts: 423
Joined: 2011-03-15 15:22

Re: Remapping Caps Lock to "menu"

#8 Post by shep »

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.

thunderogg
Posts: 198
Joined: 2008-12-10 20:12

Re: Remapping Caps Lock to "menu"

#9 Post by thunderogg »

I did it in /etc/default/keyboard.

Code: Select all

XKBOPTIONS="caps:menu"
Works fine for xfce4.
Debian 12 / Xfce4

kriukov
Posts: 11
Joined: 2017-01-19 07:08
Location: Mexico City

Re: Remapping Caps Lock to "menu"

#10 Post by kriukov »

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.

thunderogg
Posts: 198
Joined: 2008-12-10 20:12

Re: Remapping Caps Lock to "menu"

#11 Post by thunderogg »

Debian 12 / Xfce4

User avatar
debiman
Posts: 3063
Joined: 2013-03-12 07:18

Re: Remapping Caps Lock to "menu"

#12 Post by debiman »

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
Gaius
Posts: 33
Joined: 2012-12-18 10:54
Location: Germany

Re: Remapping Caps Lock to "menu"

#13 Post by Gaius »

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

Post Reply