Because of the layout of my keyboard, I want to have numlock permanently pressed and use the numlock key as a delete key. I can't seem to get this to work. Any ideas on how to do this would be appreciated.
Edit: I am running on Ubuntu 16
Here is what I have tried:
Use Xmodmap with numlockx
Inspired by this question. My understanding is that xmodmap is deprecated, so this is probably not a great idea.
- Create a file
~/.Xmodmap
with linekeycode 77 = Delete NoSymbol
- Run
xmodmap ~/.Xmodmap
- Run
numlockx on
This allows numlock to work as delete and enables the num pad until the first time I press the numlock key. Then the numlock key disables the num pad.
Use XKB
- Edit
/usr/share/X11/xkb/symbols/us
to havekey <NMLK> { [Delete, Num_Lock] };
at the end of the basic keymap. - restart computer
also tried:
- Edit
/usr/share/X11/xkb/symbols/us
to havereplace key <NMLK> { [Delete, Num_Lock] };
at the end of the basic keymap. - restart computer
This suffers from similar problems as the other method, being able to delete works, but the numlock key turns off the numpad. It also seems to mess with other keys like the windows key when the num pad is enabled. I do like that I get control of the numlock using shift+numlock. I can't find any difference between using replace and not using it.
Best Answer
Here is a way to do this using only xkb, which I think is superior to using xmodmap. This answer includes more details on what I wanted to achieve than the original question did. Xmodmap and xkb don't always play well together, this approach allows a lot more flexibility:
This is all coming from: https://wiki.archlinux.org/index.php/X_keyboard_extension
There is a list of available keysyms that seem to work here: http://docs.ev3dev.org/projects/grx/en/ev3dev-stretch/c-api/input_keysyms.html
This is being done manually to allow you to start with the configuration that is already there on your computer to prevent compatibility issues with different keyboards. Examples of prior runs of this are seen in
config_files/linux/keyboards
Begin by running
xkbcomp $DISPLAY output.xkb
to get your current keyboard settings. Then add:to the compatibility section of the generated file.
To the bottom of the types section, add:
Search for
interpret Caps_Lock
and change theLockMods
toSetMods
so that caps lock only sets the modifier, doesn't lock it.To allow capslock + WASD to work as arrow keys: edit the keys
<AD02>
,<AC01>
,<AC02>
,<AC03>
to have typeCUST_CAPSLOCK
and have respectivelyosfUp
,osfLeft
,osfDown
,osfRight
in the third position.To allow capslock + HJKL to work as arrow keys: edit the keys
<AC06>
,<AC07>
,<AC08>
,<AC09>
to have typeCUST_CAPSLOCK
and have respectivelyosfLeft
,osfDown
,osfUp
,osfRight
in the third position.To allow capslock + 0 to register as home and capslock + $ to register as end: edit the keys
<AE04>
and<AE10>
to have typeCUST_CAPSLOCK
and have respectivelyosfEndLine
andosfBeginLine
in the the third position.To allow capslock + space bar to register as escape (handy for vim) edit the key
<SPCE>
to have typeCUST_CAPSLOCK
, havespace
in the second position andosfEscape
in the third position.To turn the numlock key into a delete key and make capslock + numlock make the
<NMLK>
have typeCUST_CAPSLOCK
, have position one and two haveosfDelete
and posiition three haveNum_Lock
Now upload the changed file back into the server with:
xkbcomp output.xkb $DISPLAY
.If everything works, put file somewhere,
~/.Xkeymap
works and create a script for example named~/start_keyboard.sh
with:Make it executable (
chmod u+x ~/start_keyboard.sh
) and add the script to your startup applications.