Skip to content

Instantly share code, notes, and snippets.

@jogo3000
Created December 6, 2020 06:28
Show Gist options
  • Save jogo3000/6df215f4a30a5fab7be09c7b876e2ab0 to your computer and use it in GitHub Desktop.
Save jogo3000/6df215f4a30a5fab7be09c7b876e2ab0 to your computer and use it in GitHub Desktop.
Temporarily disables mouse when I'm typing
;; Disable mouse on typing
(defvar jogo3000/mouse-disabled nil)
(use-package disable-mouse)
(defun jogo3000/disable-mouse ()
"Disable mouse."
(setq jogo3000/mouse-disabled t)
(global-disable-mouse-mode t))
(defun jogo3000/enable-mouse ()
"Enable mouse."
(global-disable-mouse-mode -1)
(setq jogo3000/mouse-disabled nil))
(defun jogo3000/temporarily-disable-mouse ()
"Temporarily disable mouse."
(unless jogo3000/mouse-disabled
(jogo3000/disable-mouse)
(run-with-timer 2 nil 'jogo3000/enable-mouse)))
(defun jogo3000/disable-touchpad-mode ()
"Make it so that touchpad is inactive when I type."
(interactive)
(add-to-list 'post-self-insert-hook 'jogo3000/temporarily-disable-mouse))
@jcburley
Copy link

Very helpful, thanks!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment