If you are using two or more languages in your computer, this is one of the first problems you will encounter in i3wm.
So here it goes like this:
First: You should lookup for your wanted language-layout option name in output of the command below.
localectl list-x11-keymap-layouts
After that: place following code on your i3 configuration.
exec_always "setxkbmap -model pc104 -layout us,ir -variant ,, -option grp:alt_shift_toggle"
replace ir
with yours. ir
is a layout name for Persian language ( my native language ).
After that, reload the i3 configuration and thats should work.
Lets break that command above :
exec_always
: In the context of i3wm, this command basically execute the command that you write in front of it ,always when i3wm initialized.
setxkbmap
: This command in Linux is used to set the keyboard layout and options for the X Window System ( X.org is the open-source implementation of the X Window System and i3 is based on xorg )
-model pc104
: This specifies the keyboard model. The pc104 is actually what we call a full size keyboard ( with numpad and etc, 104 keys in total )
-layout us,ir
: This option specifies the keyboard layouts to be used.
-variant ,,
: This specifies the variants of the specified layouts. we leave it empty so it uses the default variant.
-option grp:alt_shift_toggle
: This sets options for switching between the specified keyboard layouts. I think the command itself is self-explanatory.