Fix laggy key presses
If key presses are slow or laggy, check the system configuration, for example on Ubuntu you can configure keyboard repeat interval and delay:
gsettings set org.gnome.desktop.peripherals.keyboard repeat-interval 3
gsettings set org.gnome.desktop.peripherals.keyboard delay 150
On KDE you can open a window to change the ‘Delay’ and ‘Rate’:
systemsettings5 kcm_keyboard
On OSX, if holding down a key does not repeat the command (a feature of OSX), you make a key repeat by running this once at the terminal:
defaults write com.sublimetext.3 ApplePressAndHoldEnabled -bool false
In general if you are on X11 type systems you could directly use:
xset r rate <milliseconds_before_repeating> <repetitions_per_second>
Ubuntu
You can adjust the delay and repeat interval via the Settings GUI.
Settings → Universal Access → Typing → Repeat Keys
Adjust the delay and speed to taste.
To script it use gsettings.
gsettings set org.gnome.desktop.peripherals.keyboard delay 150
gsettings set org.gnome.desktop.peripherals.keyboard repeat-interval 3