Ubuntu – Mouse Keys can only be disabled for current session


I've had this problem in 17.10 and 16.04, and now I'm having it again in 18.04 on a fresh install of Ubuntu. Put simply, after booting, any attempt to use the numpad in a desktop environment results in the behaviour associated with the Mouse Keys feature.

At present, the only thing I can do is go into the settings, under the Universal Access section where Mouse Keys is located, and turn it off. Oddly enough, it already shows that it is off, which means I must first turn the feature on, then off, so that the function is disabled.

Toggling the feature is all well and good, but once the session ends and I restart the system, I'm back to square one, and have to toggle it again.

Is there a fix for this bug? If not, what is the terminal equivalent of disabling Mouse Keys? I can just add the command to the startup applications list and be done with it.

According to the list of similar questions, this issue seems to go as far back as 15.04. Possibly further.

Best Answer

  • I managed to figure out that Mouse Keys was being re-enabled whenever I used an xset command. In my case, it was "xset led on" to turn the backlight on my keyboard on.

    I managed to find a couple of scripts in the answers on this question. Most of the script is unnecessary, so it all boils down to adding the following command to your startup applications to control Mouse Keys:

    gsettings set org.gnome.desktop.a11y.keyboard mousekeys-enable false

    However, even in the terminal, it seems I needed to enable it first, then disable it. I've created the following startup script to solve the issue:

    xset led on
    gsettings set org.gnome.desktop.a11y.keyboard mousekeys-enable true
    gsettings set org.gnome.desktop.a11y.keyboard mousekeys-enable false

    If I need to disconnect and reconnect my keyboard, I also need to turn the backlight on manually. Running this script will set the keyboard up again without Mouse Keys interfering.

  • Related Question