MacBook mouse pointer lockup MacBook Pro (Retina, 15-inch, Mid 2014)

In recent days the mouse pointer will be inoperable after waking from sleep. If I cmd tab I can find the pointer, but it will not respond to trackpad movement or clicks. It does not recover if I close applications, open the force quit window or resleep. Only a reboot will bring it back.

Just now it froze as I was typing. Additionally, the character I was typing repeated, as if I was holding my finger on the key combination (it was the '$' character). Again, only a reboot would stop it.

SMC reset did not fix it.

How can I resolve this so that it does not happen again?
I had a problem similar to this and it was because of a bluetooth mouse which had been left switched on in a bag. The button was held down by something resting on it and it was overriding the trackpad. If you use the keyboard shortcut (usually cmd+spacebar) to bring up spotlight and type bluetooth you can use the down arrow key to select the bluetooth system preference and you will be able to see if there is a connected mouse there causing the problem.