Keep NumLock always on

perhaps by me accidentally hitting the NumLock key

If the keyboard is yours (rather than your employer's for example), just remove it from the keyboard physically.

You can still press it with a pointy thing if you ever really need to.

enter image description here


pic of keyboard optionswith LinuxMint 17.2 and I imagine other versions of Ubuntu you can go to your KEYBOARD setting and then LAYOUTS on that page you will find a small "options" button.

From there go to "misc compatibility options" and check "numberic keys always enter digits"

This is a lifesaver for me. It bugs the heck out of me to type a number and be moved somewhere else on the page. Cheers! ;)


After reading all the answer here I was quite surprised to see that you can do the following.

<keybind key="Num_Lock">
  <action name="Execute">
    <command>numlockx on</command>
  </action>
</keybind>

So every time you press Num, which deactivates the numlock. It will execute numlockx on, which reactivates numlock.

The name comes from my output of xev which gave me the key code 77 and the name Num_Lock

In @MartinVegters case he needed to wait a few seconds so the numlockx on definitely gets executed after the event of Num is handled. Since there is a race condition between the handling of numlock in the kernel and the execution numlockx.

For this case you can write a small script denumlock.sh like

#!/bin/sh

sleep "$1"
numlockx on

and use it in the Key binding

<command>/bin/sh denumlock.sh 1</command>

This is dirty but it works.

What I recommend is the following which I couldn't test myself. You better follow the first answers which suggest to use

xmodmap -e 'keycode 77 = Escape'

But for LXDE you need to use the LXDE autostart mechanism which is different from the Openbox way of editing the ~/.config/openbox/autostart.

In LXDE you apparently need to edit ~/.config/lxsession/LXDE/autostart or with Lubuntu ~/.config/lxsession/Lubuntu/autostart, which holds the commands for the start up. (See Arch docs and LXDE docs) You may need to create that file and add this line.

@xmodmap -e 'keycode 77 = Escape'

Sadly, as I said I cannot test if this works, since I only have a VM running with LXDE.