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 line keycode 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.


  • Edit /usr/share/X11/xkb/symbols/us to have key <NMLK> { [Delete, Num_Lock] }; at the end of the basic keymap.
  • restart computer

also tried:

  • Edit /usr/share/X11/xkb/symbols/us to have replace 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.


Please go through the 30sec Video https://imgur.com/3eLhv14

  1. Swap the keys Num_Lock & Delete with below code in ~/.xmodmaprc file. Create the file, if you have not yet assigned for xmodmap.

Change the keycodes based on your keyboard results in below code.

keycode 77 = Delete
keycode 119 = Num_Lock
clear Mod2
add Mod2 = Num_Lock
  1. Check swapping of keys working or not after running the command xmodmap ~/.xmodmaprc
  2. If swapping of keys worked, create a startup application for xmodmap like below.

enter image description here

at this point you have achieved almost what you want that is the physical key which appears as NUMLOCK working as DEL and the physical key DEL working as NUMLOCK.

  • To toggle Numlock State On and Off you would like to use Shift+Physical Key NUMLOCK as you mentioned in the Question, this can be achieved with xbindkeys in combination with xte or xdotool etc. for simulating the Num_Lock key which is Physically the DEL key at this stage.

Paste the below code in the file ~/.xbindkeysrc.scm & REBOOT. Create the file, if not yet created for xbindkeys. Change the value "c:77" based on the results from your keyboard. by running xbindkeys --key and pressing the physical key NUMLOCK

(xbindkey '(shift "c:77") "xte 'key Num_Lock'")

This means when you press Shift+NUMLOCK it simulates the DEL key and thus changing the Num_Lock state On and Off.

In the below GIF you can observe on the top left the symbols 1 and Shift, the symbol 1 toggles as I press Shift+NUMLOCK key press and release.

enter image description here

  • Thanks for the response. This seems to suffer from the same problem I mentioned above, where the numlock key works as delete as expected, but when the numpad is enabled, the nunlock key also disables the numpad. Your solution does however improve on what I had in that it does not disable the windows key. – Michael Sobrepera Apr 5 at 21:19
  • No worries. Seems to work now. Thanks! – Michael Sobrepera Apr 8 at 18:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.