Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emacs - disable return and backspace keys

Tags:

emacs

I have recently been feeling RSI setting in (I have had it before).

I have been paying attention to what effects my hands and the right hand bending out to press the backspace and return keys seem to be causing a lot of the problem.

I have defined "M-d" to backwards delete, which works fine, and I know about "C-m" entering a newline but I still keep involuntarily pressing the actual keys so I want to disable them in emacs.

I tried this:

(global-unset-key "\r")

But this breaks "C-m" as well So I added this line:

(global-set-key "\C-m" 'newline)

But that restores the return key as well.

Please show me how to unbind just the return and backspace keys whilst maintaining the other bindings

like image 975
Anake Avatar asked Dec 26 '22 05:12

Anake


1 Answers

Setting return and backspace to do nothing should work. That is, these two lines should suffice:

(global-set-key (kbd "<return>") 'ignore)
(global-set-key (kbd "<backspace>") 'ignore)

This will leave keystrokes like C-m operational.

like image 59
shakurov Avatar answered Jan 03 '23 04:01

shakurov