Change keyboard layout

I saw this thread:

But I don't know that is necessary for me. And I don't understand how the script is working.