Emacs Customizations

Using Different Keyboards

According to many, the shortcuts used by Emacs can lead to repetitive stress injury, and many have swapped to different keyboard layouts. A description of this is found at http://xahlee.org/emacs/emacs_pinky.html

I have made a few auto-hotkey scripts for ways to deal with the ergonomics of Emacs. Each of these key bindings may be turned off and on with the scroll lock key. These also assume the standard QWERTY keyboard layout. There are a few types of auto-hot-key scripts that deal with different keyboards:

  • QWERTY (most common Keyboard)
    • Swap Control and Alt Keys (script)
    • Swap Caps Lock and Control Keys (script)
    • Set Caps Lock equal to Control (script)
    • Swap Control and Alt Keys, Set Caps Lock equal to Control (script)
  • Colemak keyboard
    • Normal Colemak (script)
    • Colemak with Control and Alt Keys Swapped (script)
  • Dvorak Keyboard
    • Normal Dvorak (script)
    • Swap Control and Alt Keys (script)
    • Swap Caps Lock and Control Keys (script)
    • Set Caps Lock equal to Control (script)
    • Swap Control and Alt Keys, Set Caps Lock equal to Control (script)
  • Dvorak-QWERTY Command
    • Normal Dvorak-QWERTY (script)
    • Swap Control and Alt Keys (script)
    • Swap Caps Lock and Control Keys (script)
    • Set Caps Lock equal to Control (script)
    • Swap Control and Alt Keys, Set Caps Lock equal to Control (script)

QWERTY Keyboard

Swapping Control and alt

Swapping Control and alt allows the user to use their thumb to press the control key.

Using Auto-hot-key, gives:

#SingleInstance force
Loop {
   If GetKeyState("ScrollLock", "T")
   {
      Suspend, Off
   } else {
      Suspend, On
   }
   Sleep, 50
}
Ctrl::Alt
Alt::Ctrl
Tab::Send {Blind}{Tab}

However, there are some alt-tab

issues, see Alt-Tab issues at autohotkey.com

Swap Caps Lock and Control

Some People Advocate swapping Caps Lock and Control Keys to keep this

#SingleInstance force
Loop {
   If GetKeyState("ScrollLock", "T")
   {
      Suspend, Off
   } else {
      Suspend, On
   }
   Sleep, 50
}
Capslock::Ctrl
Ctrl::Capslock

Set Caps Lock Equal to Control

#SingleInstance force
Loop {
   If GetKeyState("ScrollLock", "T")
   {
      Suspend, Off
   } else {
      Suspend, On
   }
   Sleep, 50
}
Capslock::Ctrl

Swap Control and Alt, CapsLock = Control

#SingleInstance force
Loop {
   If GetKeyState("ScrollLock", "T")
   {
      Suspend, Off
   } else {
      Suspend, On
   }
   Sleep, 50
}
Ctrl::Alt
Alt::Ctrl
Tab::Send {Blind}{Tab}

Colemak Keyboard

Colemak Keyboard

(Modified from Colemak distribution)

; Colemak layout for AutoHotkey (MS Windows)
; 2006-01-01 Shai Coleman, http://colemak.com/ . Public domain.
; See http://www.autohotkey.com/ for more information

; For this to work you have to make sure that the US (QWERTY) layout is installed,
; that is set as the default layout, and that it is set as the current layout.
; Otherwise some of the key mappings will be wrong.
;
; This is mainly useful for those who don't have privileges to install a new layout
; This doesn't support the international features of the Colemak layout.

#SingleInstance force
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetTitleMatchMode 3  ; Exact matching to avoid confusing T/B with Tab/Backspace.

Loop {
   If GetKeyState("ScrollLock", "T")
   {
      Suspend, Off
   } else {
      Suspend, On
   }
   Sleep, 50
}

;`::`
;1::1
;2::2
;3::3
;4::4
;5::5
;6::6
;7::7
;8::8
;9::9
;0::0
;-::-
;=::=

;q::q
;w::w
e::f
r::p
t::g
y::j
u::l
i::u
o::y
p::`;
;[::[
;]::]
;\::\

;a::a
s::r
d::s
f::t
g::d
;h::h
j::n
k::e
l::i
`;::o
;'::'

;z::z
;x::x
;c::c
;v::v
;b::b
n::k
;m::m
;,::,
;.::.
;/::/

Capslock::Backspace

Colemak Keyboard, Swap Control and Alt

(Modified from Colemak distribution)

; Colemak layout for AutoHotkey (MS Windows)
; 2006-01-01 Shai Coleman, http://colemak.com/ . Public domain.
; See http://www.autohotkey.com/ for more information

; For this to work you have to make sure that the US (QWERTY) layout is installed,
; that is set as the default layout, and that it is set as the current layout.
; Otherwise some of the key mappings will be wrong.
;
; This is mainly useful for those who don't have privileges to install a new layout
; This doesn't support the international features of the Colemak layout.

#SingleInstance force
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetTitleMatchMode 3  ; Exact matching to avoid confusing T/B with Tab/Backspace.

Loop {
   If GetKeyState("ScrollLock", "T")
   {
      Suspend, Off
   } else {
      Suspend, On
   }
   Sleep, 50
}

;`::`
;1::1
;2::2
;3::3
;4::4
;5::5
;6::6
;7::7
;8::8
;9::9
;0::0
;-::-
;=::=

;q::q
;w::w
e::f
r::p
t::g
y::j
u::l
i::u
o::y
p::`;
;[::[
;]::]
;\::\

;a::a
s::r
d::s
f::t
g::d
;h::h
j::n
k::e
l::i
`;::o
;'::'

;z::z
;x::x
;c::c
;v::v
;b::b
n::k
;m::m
;,::,
;.::.
;/::/

Capslock::Backspace

Ctrl::Alt
Alt::Ctrl
Tab::Send {Blind}{Tab}

Dvorak Keyboard

Dvorak Keyboard

; Use Scroll Lock to control keyboard ("on" is Dvorak)
; and do not let Control, Alt, or Win modifiers act on Dvorak
#SingleInstance force
; QWERTY to Dvorak mapping
Loop {
   If GetKeyState("ScrollLock", "T")
   {
      Suspend, Off
   } else {
      Suspend, On
   }
   Sleep, 50
}

-::[
=::]

q::'
w::,
e::.
r::p
t::y
y::f
u::g
i::c
o::r
p::l
[::/
]::=

;a::a
s::o
d::e
f::u
g::i
h::d
j::h
k::t
l::n
`;::s
'::-

z::`;
x::q
c::j
v::k
b::x
n::b
;m::m
,::w
.::v
/::z

Dvorak Keyboard, Swap Control and Alt

; Use Scroll Lock to control keyboard ("on" is Dvorak)
; and do not let Control, Alt, or Win modifiers act on Dvorak
#SingleInstance force
; QWERTY to Dvorak mapping
Loop {
   If GetKeyState("ScrollLock", "T")
   {
      Suspend, Off
   } else {
      Suspend, On
   }
   Sleep, 50
}

-::[
=::]

q::'
w::,
e::.
r::p
t::y
y::f
u::g
i::c
o::r
p::l
[::/
]::=

;a::a
s::o
d::e
f::u
g::i
h::d
j::h
k::t
l::n
`;::s
'::-

z::`;
x::q
c::j
v::k
b::x
n::b
;m::m
,::w
.::v
/::z
Ctrl::Alt
Alt::Ctrl
Tab::Send {Blind}{Tab}

Dvorak Keyboard, Swap Capslock and Control

; Use Scroll Lock to control keyboard ("on" is Dvorak)
; and do not let Control, Alt, or Win modifiers act on Dvorak
#SingleInstance force
; QWERTY to Dvorak mapping
Loop {
   If GetKeyState("ScrollLock", "T")
   {
      Suspend, Off
   } else {
      Suspend, On
   }
   Sleep, 50
}

-::[
=::]

q::'
w::,
e::.
r::p
t::y
y::f
u::g
i::c
o::r
p::l
[::/
]::=

;a::a
s::o
d::e
f::u
g::i
h::d
j::h
k::t
l::n
`;::s
'::-

z::`;
x::q
c::j
v::k
b::x
n::b
;m::m
,::w
.::v
/::z
Capslock::Ctrl
Ctrl::Capslock

Dvorak Keyboard, CapsLock = Control

; Use Scroll Lock to control keyboard ("on" is Dvorak)
; and do not let Control, Alt, or Win modifiers act on Dvorak
#SingleInstance force
; QWERTY to Dvorak mapping
Loop {
   If GetKeyState("ScrollLock", "T")
   {
      Suspend, Off
   } else {
      Suspend, On
   }
   Sleep, 50
}

-::[
=::]

q::'
w::,
e::.
r::p
t::y
y::f
u::g
i::c
o::r
p::l
[::/
]::=

;a::a
s::o
d::e
f::u
g::i
h::d
j::h
k::t
l::n
`;::s
'::-

z::`;
x::q
c::j
v::k
b::x
n::b
;m::m
,::w
.::v
/::z
Capslock::Ctrl


Dvorak Keyboard, Swap Control and Alt, CapsLock = Control

; Use Scroll Lock to control keyboard ("on" is Dvorak)
; and do not let Control, Alt, or Win modifiers act on Dvorak
#SingleInstance force
; QWERTY to Dvorak mapping
Loop {
   If GetKeyState("ScrollLock", "T")
   {
      Suspend, Off
   } else {
      Suspend, On
   }
   Sleep, 50
}

-::[
=::]

q::'
w::,
e::.
r::p
t::y
y::f
u::g
i::c
o::r
p::l
[::/
]::=

;a::a
s::o
d::e
f::u
g::i
h::d
j::h
k::t
l::n
`;::s
'::-

z::`;
x::q
c::j
v::k
b::x
n::b
;m::m
,::w
.::v
/::z
Ctrl::Alt
Alt::Ctrl
Tab::Send {Blind}{Tab}
Capslock::Ctrl

Dvorak-QWERTY Command Keyboard

Dvorak-QWERTY Command Keyboard

; Use Scroll Lock to control keyboard ("on" is Dvorak)
; and do not let Control, Alt, or Win modifiers act on Dvorak
#SingleInstance force
Loop {
   If GetKeyState("ScrollLock", "T")
   and !GetKeyState("Control")
   and !GetKeyState("Alt")
   and !GetKeyState("LWin")
   and !GetKeyState("RWin") {
      Suspend, Off
   } else {
      Suspend, On
   }
   Sleep, 50
}

; QWERTY to Dvorak mapping
-::[
=::]

q::'
w::,
e::.
r::p
t::y
y::f
u::g
i::c
o::r
p::l
[::/
]::=

;a::a
s::o
d::e
f::u
g::i
h::d
j::h
k::t
l::n
`;::s
'::-

z::`;
x::q
c::j
v::k
b::x
n::b
;m::m
,::w
.::v
/::z

Dvorak-QWERTY, Swap Control and Alt

#SingleInstance force
DetectHiddenWindows On
Loop {
   If GetKeyState("ScrollLock", "T")
   {
     Suspend, Off
     If GetKeyState("Control") 
       Or GetKeyState("Alt") 
       Or GetKeyState("Lwin") 
       Or GetKeyState("Rwin") 
     {
       Gui 1:Show, Hide, ModKy
     } else 
     {
       Gui 1:Destroy
     }
   } else {
      Suspend, On
   }
   Sleep, 50
}


#IfWinExist ModKy ; below the HotKeys are active when the mod keys are activated.
[::[
]::]

'::'
,::,
.::.
p::p
y::y
f::f
g::g
c::c
r::r
l::l
/::/
=::=

a::a
o::o
e::e
u::u
i::i
d::d 
h::h
t::t
n::n
s::s
-::-

`;::`;
q::q
j::j
k::k
x::x
b::b
m::m
w::w
v::v
z::z
Ctrl::Alt
Alt::Ctrl
Tab::Send {Blind}{Tab}
;...

#IfWinExist       ; below the HotKeys are active when all toggles are Off
Ctrl::Alt
Alt::Ctrl
Tab::Send {Blind}{Tab}
-::[
=::]

q::'
w::,
e::.
r::p
t::y
y::f
u::g
i::c
o::r
p::l
[::/
]::=

;a::a
s::o
d::e
f::u
g::i
h::d
j::h
k::t
l::n
`;::s
'::-

z::`;
x::q
c::j
v::k
b::x
n::b
;m::m
,::w
.::v
/::z

;...

Dvorak-QWERTY, Swap CapsLock and Control

Dvorak-QWERTY, CapsLock = Control

#SingleInstance force
DetectHiddenWindows On
Loop {
   If GetKeyState("ScrollLock", "T")
   {
     Suspend, Off
     If GetKeyState("Control") 
       Or GetKeyState("Alt") 
       Or GetKeyState("Lwin") 
       Or GetKeyState("Rwin") 
     {
       Gui 1:Show, Hide, ModKy
     } else 
     {
       Gui 1:Destroy
     }
   } else {
      Suspend, On
   }
   Sleep, 50
}


#IfWinExist ModKy ; below the HotKeys are active when the mod keys are activated.
[::[
]::]

'::'
,::,
.::.
p::p
y::y
f::f
g::g
c::c
r::r
l::l
/::/
=::=

a::a
o::o
e::e
u::u
i::i
d::d 
h::h
t::t
n::n
s::s
-::-

`;::`;
q::q
j::j
k::k
x::x
b::b
m::m
w::w
v::v
z::z
Capslock::Ctrl
;...

#IfWinExist       ; below the HotKeys are active when all toggles are Off
Capslock::Ctrl
-::[
=::]

q::'
w::,
e::.
r::p
t::y
y::f
u::g
i::c
o::r
p::l
[::/
]::=

;a::a
s::o
d::e
f::u
g::i
h::d
j::h
k::t
l::n
`;::s
'::-

z::`;
x::q
c::j
v::k
b::x
n::b
;m::m
,::w
.::v
/::z

;...

Dvorak-QWERTY, Swap Control and Alt, CapsLock = Control

#SingleInstance force
DetectHiddenWindows On
Loop {
   If GetKeyState("ScrollLock", "T")
   {
     Suspend, Off
     If GetKeyState("Control") 
       Or GetKeyState("Alt") 
       Or GetKeyState("Lwin") 
       Or GetKeyState("Rwin") 
     {
       Gui 1:Show, Hide, ModKy
     } else 
     {
       Gui 1:Destroy
     }
   } else {
      Suspend, On
   }
   Sleep, 50
}


#IfWinExist ModKy ; below the HotKeys are active when the mod keys are activated.
[::[
]::]

'::'
,::,
.::.
p::p
y::y
f::f
g::g
c::c
r::r
l::l
/::/
=::=

a::a
o::o
e::e
u::u
i::i
d::d 
h::h
t::t
n::n
s::s
-::-

`;::`;
q::q
j::j
k::k
x::x
b::b
m::m
w::w
v::v
z::z
Capslock::Ctrl
Ctrl::Alt
Alt::Ctrl
Tab::Send {Blind}{Tab}
;...

#IfWinExist       ; below the HotKeys are active when all toggles are Off
Capslock::Ctrl
Ctrl::Alt
Alt::Ctrl
Tab::Send {Blind}{Tab}
-::[
=::]

q::'
w::,
e::.
r::p
t::y
y::f
u::g
i::c
o::r
p::l
[::/
]::=

;a::a
s::o
d::e
f::u
g::i
h::d
j::h
k::t
l::n
`;::s
'::-

z::`;
x::q
c::j
v::k
b::x
n::b
;m::m
,::w
.::v
/::z

;...