Languages: [🇪🇸] Español - [🇺🇸] English
When I started to work I remember a senior developer advise:
Install and use everything in English. The whole developer world is focused on English first. Your life will be easier because when you found an error only need to copy it and paste it on a search engine, sure you will find that this question was already made.
catch(error){
console.log(`https://stackoverflow.com/search?q={error.message}`)
}
So, the first time that I see this joke, his words got sense. 😎
Last few days, I started to see a lot of non-American developers (Latam, Spain, France, Germany, India, and Hungary) that recommend moving to use the en-US keyboard layout.
And again his advise came before my very eyes:
If we are using the software in English and write code in English. Why not use hardware too?
Programming languages, IDEs, and Code Editors were designed and developed to use in English first, and if I'm not wrong I'm very sure were written with an English keyboard.
When these people were changed to this layout says that feel more natural, comfortable, and productive. I think this is due because symbols and keyboard shortcuts are made to use with en-US keyboard layout. I don't know if I'm right or not, but it has a lot of sense to me.
Switching to en-US keyboard also comes with an added benefit: never will be easy to buy a mechanical keyboard. For me, it's very hard or even impossible to found a good keyboard with es-LATAM layout.
Sound good, but... where are the accents? and the
Ñ
letter?
Quick Solution
Everyone who needs any sort of diacritic or accent would ask the same question because the use en-US layout makes it unsuitable unless the US International layout is used.
This layout changes the `
(grave), ~
(tilde), ^
(circumflex), "
(double quote, to make diaeresis), and '
(apostrophe, to make acute accent) keys into dead keys for producing accented characters: thus for example '
(release) a
will produce á
. The US International layout also uses the AltGr (Alt+Ctrl) as a modifier to enter special characters.
But this International layout has a critical downside (at least on Windows) for programming due to dead keys. We are going to lose speed because need to press two keys instead of one: the diacritic or accent followed by an ending character (space, tab or enter) to produce it.
So what can we do?
Just roll back to en-US layout and create a customs script for diacritic or accent.
Custom Solution
TLDR if you are not interested in the dirty aspects can jump directly to the Summary
I will detail the process to create a script to use with AutoHotKey for Spanish accents (my native language) and you can use it as an example in case you need to create your own.
- First, you need to recognize the accents
áéíóúñ
letters and symbols¡¿
that you want to remap and search his correspondent decimal value on the ASCII table.
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.
Char | Modifier |
---|---|
^ | Ctrl |
! | Alt |
+ | Shift |
# | Win |
< | Left |
> | Right |
- Create a script file called
en-US_accents.ahk
adding the remap configuration.
!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 -> Ñ
It was easy!
Not too fast my friend. We recently defined the shortcut Alt+Shift+A
, but for example, VSCode also uses this same shortcut to toggle comments.
We need to change the Left Alt as a modifier, updating all the Alt+Shift+
maps to only works with (Right)Alt+Shift+
. Just change !+
modifiers with >!+
.
Now you can still use the (Left)Alt+Shift+a
on VScode and (Right)Alt+Shift+a
to write the Á
(with accent). It's up to you if you like to convert all Alt modifiers to (Right)Alt or only the combinations with conflicts.
!a:: Send {Asc 0225} ; Alt+a -> á
>!+a:: Send {Asc 0193} ; Shift+(Right)Alt+a -> Á
!e:: Send {Asc 0233} ; Alt+e -> é
>!+e:: Send {Asc 0201} ; Shift+(Right)Alt+e -> É
!i:: Send {Asc 0237} ; Alt+i -> í
>!+i:: Send {Asc 0205} ; Shift+(RightAlt+i -> Í
!o:: Send {Asc 0243} ; Alt+o -> ó
>!+o:: Send {Asc 0211} ; Shift+(Right)Alt+o -> Ó
!u:: Send {Asc 0250} ; Alt+u -> ú
>!+u:: Send {Asc 0218} ; Shift+(Right)Alt+u -> Ú
!n:: Send {Asc 0241} ; Alt+n -> ñ
>!+n:: Send {Asc 0209} ; Shift+(Right)Alt+n -> Ñ
Woohoo! Amazing!
Additionally in Spanish, the exclamation and question mark symbols need to be open at the beginning and close at the end.
!/:: Send {Asc 0191}{Asc 63}{left 1} ; Alt+/ -> ¿?
!1:: Send {Asc 0161}{Asc 33}{left 1} ; 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.
Extra
If it's not enough. I have other cool optional tricks.
If you already have a keyboard with a number pad at the right. Why not use the numbers row directly with symbols when Num Lock is active?
#if GetKeyState("NumLock", "T")
*1::!
*2::@
*3::#
*4::$
*5::Send `%
*6::^
*7::&
*8::Send `*
*9::(
*0::)
$+1::Send 1
$+2::Send 2
$+3::Send 3
$+4::Send 4
$+5::Send 5
$+6::Send 6
$+7::Send 7
$+8::Send 8
$+9::Send 9
$+0::Send 0
#if
Those who use a Laptop or a TKL (Ten Key Less) keyboards can use
Insert
instead ofNumLock
or remove the if condition.
And how many times did you use the Caps Lock
key? For me as developer results more useful to remap it as Backspace
and have it directly on the home row.
CapsLock::Backspace
!CapsLock::CapsLock
But if sometimes you will need to use the Caps Lock
, for example for writing SQL, can be enabled/disable with Alt+CapsLock
Summary
Finally, we will have a compatible, fast, reliable, and useful en-US layout keyboard for development without leaving Qwerty.
With a simple AutoHotkey script:
#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.
; Modifiers
; ^ Ctrl
; ! Alt
; + Shift
; # Win
; < Left
; > Right
; Action
CapsLock::Backspace
!CapsLock::CapsLock ; Alt+CapsLock -> Enable/Disable Caps Lock
PrintScreen::Send #+s
; Accents
!a:: Send {Asc 0225} ; Alt+a -> á
>!+a:: Send {Asc 0193} ; Shift+(Right)Alt+a -> Á
!e:: Send {Asc 0233} ; Alt+e -> é
>!+e:: Send {Asc 0201} ; Shift+(Right)Alt+e -> É
!i:: Send {Asc 0237} ; Alt+i -> í
>!+i:: Send {Asc 0205} ; Shift+(RightAlt+i -> Í
!o:: Send {Asc 0243} ; Alt+o -> ó
>!+o:: Send {Asc 0211} ; Shift+(Right)Alt+o -> Ó
!u:: Send {Asc 0250} ; Alt+u -> ú
>!+u:: Send {Asc 0218} ; Shift+(Right)Alt+u -> Ú
!n:: Send {Asc 0241} ; Alt+n -> ñ
>!+n:: Send {Asc 0209} ; Shift+(Right)Alt+n -> Ñ
; Symbols
!/:: Send {Asc 0191}{Asc 63}{left 1} ; Alt+/ -> ¿?
!1:: Send {Asc 0161}{Asc 33}{left 1} ; Alt+1 -> ¡!
; Swap Numbers Row
#if GetKeyState("NumLock", "T")
*1::!
*2::@
*3::#
*4::$
*5::Send `%
*6::^
*7::&
*8::Send `*
*9::(
*0::)
$+1::Send 1
$+2::Send 2
$+3::Send 3
$+4::Send 4
$+5::Send 5
$+6::Send 6
$+7::Send 7
$+8::Send 8
$+9::Send 9
$+0::Send 0
#if
I know there are a lot of keyboard layouts like Dvorak, Colemak, Workman, Norman, and so on. I've tested a pair of them and I convinced myself that there is no perfect layout to rule them all.
But with the changes I propose to introduce with AutoHotkey, you will still be using Qwerty and will not have too many problems in case you will need to use another computer or someone use yours.
The good thing is that we have multiple options depending on our needs and tastes. Choose wisely whatever you think it's better for you.
One last shout-out. If you are a software developer, also be cool to use these JS/TS operators shortcuts.
Javascript Operators with AutoHotKey
Camilo Martinez ・ Jun 21 '21
Sources:
That’s All Folks!
Happy Coding 🖖
Top comments (0)