I am running mojave (10.14.2) on a 2018 macbook. I keep accidentally hitting the trackpad while typing. None of the solutions in this question still work. Does an updated solution exist?
The simplest solution I've found which works on any recent version of MacOS is turn off
tap to click in
System Preferences > Trackpad > Point & Click.
You can use this applescript to quickly toggle tap-to-click on and off. On MacOS open
Applications > Utilities > Script Editor and paste the code from this script:
tell application "System Preferences"
reveal anchor "trackpadTab" of pane "com.apple.preference.trackpad"
tell application "System Events" to tell process "System Preferences"
click checkbox 3 of tab group 1 of window 1
quit application "System Preferences"
File > Export and save in
Applications but also make sure to select
File Format > Application before saving.
If you want to make it very easy to run the toggle on and off, you may want to add a custom keyboard shortcut which would just run the toggle application.