Can't lock Touchpad on Ubuntu 18.04.2 LTS

Since Toggling Button on Keyboard is not working as expected..

here is a workaround..

  1. run xmodmap -pke | grep TouchpadToggle
  2. check the symbol on keyboard which is given for Toggling of Touchpad.. in mycase it is on F5 #Change F5 with your key on keyboard
  3. run xmodmap -pke | grep F5
  4. run xmodmap -e "keycode 71 = XF86TouchpadToggle" #Change 71 with your output.

Example:

$ xmodmap -pke | grep TouchpadToggle
keycode 199 = XF86TouchpadToggle NoSymbol XF86TouchpadToggle
$ xmodmap -pke | grep F5
keycode  71 = F5 F5 F5 F5 F5 F5 XF86Switch_VT_5
xmodmap -e "keycode 71 = XF86TouchpadToggle"
$ 

that's it.. Please note that you will loose the original function of F5 key with this workaround.. eventhough xmodmap shows upto 8 keys can be configured, but it seems with Function Keys it is not happening..

From man xmodmap

The list of keysyms is assigned to the indicated keycode (which may be specified in decimal, hex or octal and can be determined by running the xev program). Up to eight keysyms may be attached to a key, however the last four are not used in any major X server implementation. The first keysym is used when no modifier key is pressed in conjunction with this key, the second with Shift, the third when the Mode_switch key is used with this key and the fourth when both the Mode_switch and Shift keys are used.

Please note that you can bind XF86TouchpadToggle to any key you wish, all you need is just go through man xmodmap

I have tried this in dual boot Windows10 and Ubuntu 18.04.. as you said in comments, in Windows10 Fn+F5 key worked as expected and my F5 key has the symbol for TogglingTouchPadOn/Off and this did not work in Ubuntu 18.04.. seems the reason is clearly visible that by default it is mapped to keycode 199 which I dont have with my present keyboard. So it is need to map the keysym XF86TouchpadToggle to any desired key.

enter image description here .