Hot answers tagged

51

There are a lot of players between your keyboard and the process that finally handles the keyboard event. Among the major pieces of the landscape are the fact that the X system has its own keyboard-handling layer, and X associates different "keycodes" with keys than your Linux base system does. The showkey command is showing you the keycodes in Linux-base-...


48

On Lenovo Thinkpad Edge, press Fn+Esc and Fn key will light up and you can use F1-F12 keys as default.


28

Mode_switch is the old-style (pre-XKB) name of the key that is called AltGr on many keyboard layouts. It is similar to Shift, in that when you press a key that corresponds to a character, you get a different character if Shift or AltGr is also pressed. Unlike Shift, Mod_switch is not a modifier in the X11 sense because it normally applies to characters, not ...


28

I think I have a technique for disabling the toggling of the Capslock key but not completely disabling the key all together, or remapping it to another key on the keyboard. If you use the command: setxkbmap -option caps:none The keyboard will no longer toggle. I've confirmed this on my laptop running Fedora 14, the LED no longer lights up, and normal ...


24

xev should work Odd, my xev gives a KeyPress and KeyRelease event for alt (and for the Windows key, here called "super"): KeyPress event, serial 40, synthetic NO, window 0xae00001, root 0x2ca, subw 0x0, time 595467354, (98,77), root:(102,443), state 0x10, keycode 64 (keysym 0xffe9, Alt_L), same_screen YES, XLookupString gives 0 bytes: ...


19

There are a bajillion answers on the internet, most of them confusing. The key is you need to map 'keycode 66' to your hyper key, remove the mapping of that key from other mod{1,2,4,5}'s (only if present), and then set mod3. Open ~/.Xmodmap and put the following: ! Unmap capslock clear Lock keycode 66 = Hyper_L ! Leave mod4 as windows key _only_ remove ...


17

You can accomplish this with xmodmap. Add the following to ~/.xmodmap: remove Lock = Caps_Lock keysym Caps_Lock = Control_L add Control = Control_L and run the command xmodmap ~/.xmodmap. You can put this command in whatever startup files are processed by your WM or DE. This will only work in X but it will work regardless of what graphical environment ...


16

I found it. It was moved to the regional preferences section: Go to settings > regional preferences > keyboard layouts > settings and expand the caps lock section. UPDATE: In Linux Mint 17.1 you can get to it via; System Settings > Hardware > Keyboard > Keyboard Layouts > Options > Caps Lock key behavior


15

I "detect" three issues in your question: Why do xev and showkey report different keycodes for a key? Why does xev not show Alt being pressed properly? How to swap Alt and Win? Regarding the first question: these days, where the keyboard "driver" in X does not really drive the hardware, it could just pass-through the keycodes from the kernel to the X core, ...


13

Execute xfce4-settings-manager, in Session and Startup -> Application autostart, add an entry, which executes xmodmap ~/.xmodmap Or rename the file to ~/.Xmodmap


12

There is a package in community numlockx: # pacman -S numlockx and then add it to your .xinitrc: numlockx & There are also methods on the the Arch Wiki if you are using a login manager, such as GDM or KDM: https://wiki.archlinux.org/index.php/Activating_Numlock_on_Bootup


12

Alternative solution After finishing writing the answer bellow, I realized that what you're trying to achieve could be accomplished much more elegantly with the help of xinput or even using Xorg's config. Make sure to read the documentation about controlling input devices in Xorg. Using udev (an answer to your question) According to my tests there are ...


11

The following commands should work: xmodmap -e 'keycode 0x42 = Caps_Lock' or setxkbmap -option The commands above work just fine to restore the default behaviour, which I hardly ever need, luckily. I normally remap the capslock to Control (luckily VI/VIM supports CTRL-C instead of ESC) with the following command: setxkbmap -option ctrl:nocaps -layout ...


11

As root, run: showkey -s ...to see what the scancode is for your mystery key. I got something like this: # showkey -s kb mode was RAW [ if you are trying this under X, it might not work since the X server is also reading /dev/console ] press any key (program terminates 10s after last keypress)... 0xc6 0x46 0xc6 0xc6 0x46 0xc6 0x46 Not sure why it ...


11

I was trying to solve this for myself and I just figured it out. The main problem is that you aren't getting the event for the keypress. Looking at the log you posted the reason is apparent. FocusOut event, serial 36, synthetic NO, window 0x4a00001, mode NotifyGrab, detail NotifyAncestor FocusIn event, serial 36, synthetic NO, window 0x4a00001, ...


10

Press Fn + Num Lock to disable it.


10

This answer is not meant to contradict @Gilles' answer, but is meant to describe another aspect of xkb Input handling which I feel is "under-illuminated" in his answer. You can use both ISO_Level3_Shift(Alt-Gr) and Mode_switch at the same time with different results. It requires some configuration, but you can have them both, and use them to produce 6 ...


8

The files altered by gnome-tweak-tool are ~/.config/dconf/user (this is the dconf database, a binary file where most user settings are stored) and various other configuration files under ~/.config (these are all text files) In this particular case - changing the typing settings - gnome-tweak-tool alters the xkb-options in the dconf database. It's easy to ...


7

The xmodmap(1) man page has an example for exactly this ! ! Swap Caps_Lock and Control_L ! remove Lock = Caps_Lock remove Control = Control_L keysym Control_L = Caps_Lock keysym Caps_Lock = Control_L add Lock = Caps_Lock add Control = Control_L but if you want to finish doing it the way you started, I think you need to add at ...


7

Reset the map to its original state before applying your mods. A full reset takes forever, so best I can come up with is diffing. This code uses .Xmodmap{.orig,.reset,.mods} where if .orig doesn't exist it's set to the current state, and calculates .reset to restore that state from wherever it's got to. before applying .mods. #!/bin/sh # file xmodmap-reset ...


7

You are having problems with idempotency because you are using keysym instead of keycode. Think of keycode as being an assignment of a key to a function, while keysym is just a link from a function name to an actual function. When you use keysym as follows: keysym Caps_Lock = Multi_key you essentially delete the name Caps_Lock. Therefore, the next time ...


7

Using xmodmap to configure individual key mappings It is time to write down results of my own research. I thought that I must have missed something in xmodmap and that it is just not very well documented and people are confused. But it turned out that X.Org design regarding XKB and xmodmap is just stupid. Epic fail: xmodmap You can use xmodmap to ...


6

X normally has 8 modifiers, which have keysyms assigned to them. Pressing a key results in a keyboard event that's associated with the keysym. If the keysym has a modifier assigned to it, then while that key is down, key events will be tagged with that modifier. The modifiers, together with common keysym assignments, are: Shift: Shift_L, Shift_R Lock: ...


6

xkb has an option that does just that: caps:swapescape Swap ESC and Caps Lock so you could simply add1 /usr/bin/setxkbmap -option "caps:swapescape" to your XFCE autostart items. 1: there might be a better way to do this but I'm not a XFCE user


6

I assume you're trying to do this in shell or similar (else, you'd just use the X libraries directly). If so, you may find xinput --test «device-name» much easier to parse. Unfortunately, it really isn't shell-scripting friendly. But you can make it work with stdbuf. It runs until you kill it, but your shell script could pipe it to read. So, you can do ...


6

I'd better answer my own question for future reference. After a bit of in-depth research, I found out that xmodmap is actually deprecated and is roughly patched over the xkb keyboard model. The xkb model doesn't use a linear array of alternatives, but splits layouts into groups, with each group having a couple of characters in different shift levels. The ...


6

Make your own xkb configuration file The idea is to "read" the current keyboard config (do not call xmodmap), and write your own symbols file based on it. First: xkbcomp -xkb $DISPLAY This creates server-0_0.xkb. In this file, take the following block: xkb_symbols "pc+inet(evdev)+compose(menu)+whatever(option)" { key <ESC> { [ Escape ] }; .....


5

Yes: xinput set-button-map ID <button map> Where you find the ID via xinput list and the <button map> is what you would have passed to xmodmap. For instance I replace buttons on my USB mouse but I don't want my trackpad munged, my ~/.Xmodmap used to look like this: pointer = 1 17 3 4 5 6 7 8 9 10 11 12 13 14 15 16 2 18 19 20 21 22 23 24 But ...


5

Run the command xev. In the xev window, press the AltGr key. You'll see something like KeyPress event, serial 29, synthetic NO, window 0x6400001, root 0x105, subw 0x0, time 966635535, (243,-207), root:(1891,26), state 0x0, keycode 66 (keysym 0xff7e, Mode_switch), same_screen YES, XLookupString gives 0 bytes: XmbLookupString gives 0 bytes: ...


Only top voted, non community-wiki answers of a minimum length are eligible