2

I have a work laptop with numpad keys, and the navigation keys (home/end, page up/down, insert, delete) are also there. And their behavior depends on Numlock key state.

I don't have a habit of using numpad digits - in fact, I don't need them at all. But I need home, end, insert, delete and combinations with them. And now I accidentally press that Numlock 100 times per day (it's too close to Return) and getting 7, when I need to select text, 0 when need insert text, and so on.

I am starting to hate this key.

I tried to use Tweaks, but "as in Windows" is not what I need, and "as in MacOps" produce only digits.

I need visa-versa: completely get rid of digits from numpad and disable numlock. End should set cursor to the line end, and shift+end should select text from cursor position to the line end - no matter what.

Is that possible?

Marry
  • 23
  • 3
  • 1
    Yes. see https://askubuntu.com/questions/974040/how-do-you-re-map-a-numpad for instance (uses xev and xmodmap) Older but with images https://askubuntu.com/questions/296155/how-can-i-remap-keyboard-keys – Rinzwind Apr 19 '19 at 11:53

3 Answers3

0

The links provided by @Rinzwind are very useful and I upvote his comment, I thought to write below steps just to let you get quick output/ result what you are looking for, I recommend you to follow those links to understand the concept and become master in mappings..

  1. Turn off the Num_Lock key.

  2. run xmodmap command in terminal..

you will get the result similar to below..

pratap@i7-6550U:~$ xmodmap
xmodmap:  up to 4 keys per modifier, (keycodes in parentheses):

    shift       Shift_L (0x32),  Shift_R (0x3e)
    lock      
    control     Control_L (0x25),  Control_R (0x69)
    mod1        Alt_L (0x40),  Alt_R (0x6c),  Meta_L (0xcd)
    mod2        Num_Lock (0x4d)
    mod3      
    mod4        Super_L (0x85),  Super_R (0x86),  Super_L (0xce),  Hyper_L (0xcf)
    mod5        ISO_Level3_Shift (0x5c),  Mode_switch (0xcb)

pratap@i7-6550U:~$ 

note that Num_Lock is for mod2

  1. we need to Remove Num_Lock from mod2 with below command in terminal

xmodmap -e "remove mod2 = Num_Lock"

Example:

pratap@i7-6550U:~$ xmodmap -e "remove Mod2 = Num_Lock"
pratap@i7-6550U:~$

since we removed Num_Lock from mod2 when the Num_Lock state is off, there will be no effect even we press Num_Lock here onwards.. hence its state is always off.

this command in terminal will not persist after a logout or reboot.. so add this command to startup applications like below..

enter image description here

When ever you want to operate Num_Lock key in a running session, you can run below command xmodmap -e "add mod2 = Num_Lock"

when you want to get rid of all these changes and want the default behaviour.. remove the startup command we added.

PRATAP
  • 22,460
0

Using gsettings (front-end to dconf) in terminal:

Turn off NumLock with (copy/paste):

gsettings set org.gnome.settings-daemon.peripherals.keyboard numlock-state 'off'

Remember NumLock settings with (copy/paste):

gsettings set org.gnome.settings-daemon.peripherals.keyboard remember-numlock-state true

View those settings as required:

gsettings get org.gnome.settings-daemon.peripherals.keyboard numlock-state

and

gsettings get org.gnome.settings-daemon.peripherals.keyboard remember-numlock-state
Broadsworde
  • 4,132
  • 4
  • 28
  • 45
0

On Ubuntu 20.04, apparently they changed the gsettings schema. Found the numlock settings under org.gnome.desktop (instead of org.gnome.settings-daemon)

So on 20.04, use:

gsettings set org.gnome.desktop.peripherals.keyboard numlock-state false
gsettings set org.gnome.desktop.peripherals.keyboard remember-numlock-state true

You can also use

gsettings list-recursively

to list all keys and values.

dbtrnl
  • 1
  • 1
  • 2