Skip to content

Instantly share code, notes, and snippets.

@anderssonjohan
Last active November 1, 2021 23:32
Show Gist options
  • Save anderssonjohan/e4249e878bdd9ee568571d6445701f9c to your computer and use it in GitHub Desktop.
Save anderssonjohan/e4249e878bdd9ee568571d6445701f9c to your computer and use it in GitHub Desktop.
My us dvorak key mappings for Swedish characters åäö + mac key bindings for swapping LAlt->LCtrl, LCtrl->LWin, LWin->LAlt
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
; Keys on dell laptop: LCtrl, Fn, LWin, LAlt
; Result: LWin, Fn, LAlt, LCtrl
; ..to get Ctrl next to spacebar so most Cmd key bindings are where the mac user muscle memory says they should be :)
LWin::LAlt
LAlt::LCtrl
LCtrl::LWin
RWin::RAlt
RAlt::RWin
!':: Send, å ; Alt-Q
!,:: Send, ä ; Alt-W
!.:: Send, ö ; Alt-E
!+':: Send, Å ; Alt-Shift-Q
!+,:: Send, Ä ; Alt-Shift-W
!+.:: Send, Ö ; Alt-Shift-E
; This reverts the Alt+Tab behavior
^Tab::
Send, {LAlt Down}{Tab}
ReleaseLAlt(10000)
; The purpose of this function is to release the LAlt key
; Without this, the LAlt key will be stuck
ReleaseLAlt(timeout := "")
{
startTime := A_Tickcount
while (isaKeyPhysicallyDown("LAlt"))
{
if (timeout && A_Tickcount - startTime >= timeout)
Send, {LAlt Up} ; Took too long
sleep, 50
}
Send, {LAlt Up}
}
isaKeyPhysicallyDown(Keys)
{
if isobject(Keys)
{
for Index, Key in Keys
if getkeystate(Key, "P")
return key
}
else if getkeystate(Keys, "P")
return Keys ;keys!
return 0
}
![::Send !{Left}
!]::Send !{Right}
!a::Send ^a
!b::Send ^b
!c::Send ^c
!d::Send ^d
!e::Send ^e
!f::Send ^f
!g::Send ^g
!h::Send ^h
!i::Send ^i
!j::Send ^j
!k::Send ^k
!l::Send ^l
!m::Send ^m
!n::Send ^n
!o::Send ^o
!p::Send ^p
!q::Send ^q
!r::Send ^r
!s::Send ^s
!t::Send ^t
!u::Send ^u
!v::Send ^v
!w::Send ^w
!x::Send ^x
!y::Send ^y
!z::Send ^z
!Right::
Send {End}
return
*!Right:: ; This handles Shift-Right
Send {Blind}{LAlt Up}{End}
return
!Left::
Send {Home}
return
*!Left:: ; This handles Shift-Left
Send {Blind}{Alt Up}{Home}
return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment