Accents on Dvorak with AutoHotkey
Tags: productivity, tutorial, dvorak, keyboard
Published: 2021-03-02 19:00:04

Maybe you may know that there is no available International distribution for the Dvorak keyboard. At most, you will find the US distribution.

But if you are like me, that need accents because of my native language (Spanish) is there a way to add it with an [AutoHotKey](https://www.autohotkey.com/) script.

I will detail the process for Spanish accents and you can use it as an example in case you need to create your own.

---

# Steps

- First, you need to recognize the accents `áéíóú`, letters and `ñ` and symbols `¡¿` that you want to remap and search his correspondent decimal value on the [ASCII table](https://www.ascii-code.com/).

|Char|Dec|Char|Dec|
|---|---|---|---|
|á|0225|Á|0193|
|é|0233|É|0201|
|í|0237|Í|0205|
|ó|0243|Ó|0211|
|ú|0250|Ú|0218|
|ñ|0241|Ñ|0209|
|¿|0191|?|63|
|¡|0161|!|33|

- Next, we need to remap each key with desired destinations following this format `OriginKey::DestinationKey` taken attention of his [modifiers keys](https://www.autohotkey.com/docs/KeyList.htm#modifier).

|Char|Modifier|
|---|---|
|^|<kbd>Ctrl</kbd>|
|!|<kbd>Alt</kbd>|
|+|<kbd>Shift</kbd>|

- Create a script file called `accent-keys.ahk` adding the remap configuration.

```c
!a::Send {Asc 0225} ; Alt+a -> á
!+a::Send {Asc 0193} ; Shift+Alt+a -> Á
!d::Send {Asc 0233} ; Alt+e -> é
!+d::Send {Asc 0201} ; Shift+Alt+e -> É
!g::Send {Asc 0237} ; Alt+i -> í
!+g::Send {Asc 0205} ; Shift+Alt+i -> Í
!s::Send {Asc 0243} ; Alt+o -> ó
!+s::Send {Asc 0211} ; Shift+Alt+o -> Ó
!f::Send {Asc 0250}  Alt+u -> ú
!+f::Send {Asc 0218} ; Shift+Alt+u -> Ú
!l::Send {Asc 0241} ; Alt+n -> ñ
!+l::Send {Asc 0209} ;  Shift+Alt+n -> Ñ
```

In Spanish, the exclamation and question mark symbols need to be open at the beginning and close at the end.

```c
!+[::Send {Asc 0191}{Asc 63}{left 1} ; Shift+Alt+[ -> ¿?
!+1::Send {Asc 0161}{Asc 33}{left 1} ; Shift+Alt+1 -> ¡!
```

The last two have another trick. It will create open and close symbols and with the `{left 1}` command move the cursor between them.

And if you work on Javascript, like me, it will be useful to create some shortcuts for logical comparison.

|Char|Dec|Char|Dec|
|---|---|---|---|
|=|61|<|60|
|!|33|>|62|

```c
!+::Send {Asc 61}{Asc 61}{Asc 61} ; Alt+= -> ===
!++::Send {Asc 33}{Asc 61}{Asc 61} ; Shift+Alt -> !==
!,::Send {Asc 60}{Asc 61} ; Alt+, -> <=
!.::Send {Asc 60}{Asc 62} ; Alt+. -> >=
```

- Finally, Save the file and open it with AutoHotkey.

# Dvorak Keyboard with Accents

![dvorak-accents](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c5rtrls3cyax4nn7il1o.png)

# Avoid override

We recently defined the shortcut `Alt+Shif+A`, but for example, VSCode also uses this same shortcut to toggle comments.

we can simulate the (AltGr) as a modifier changing all the `Alt+Shift+` maps to only works with `RightAlt+Shift+`. Just change `!+` modifiers with `>!+`.

Now you can still use the `LeftAlt+Shift+a` on VScode and `RightAlt+Shift+a` to write the `Á` (with accent). It's up to you if you like to convert all Alt modifiers to AltGr (Leftright) or only the combinations with conflicts.

---

**That’s All Folks!**
**Happy Coding** 🖖

[![beer](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mkgsx4aw6qn9i9ax6as9.png)](https://github.com/sponsors/deinsoftware)