The Shifting Keys
For bilingual users or developers, having multiple keyboard input sources (like standard US English and Spanish ISO) installed on macOS is essential. By default, macOS attempts to track which input source you are using on a per-document basis. If you switch to Spanish while writing an email in the Mail app, and then click over to your web browser (which was previously using English), macOS will automatically switch your keyboard layout back to English the moment the browser window becomes active. While this context-switching is meant to be helpful, it often results in typing entire sentences of gibberish before you realize the layout has changed without your command.
Unifying the Keyboard State
To ensure a consistent typing experience and stop macOS from automatically changing your input sources when you switch between different applications, you must force the system to use a single, global layout state.
Click the Apple logo in the top-left corner of the screen and select System Settings. Scroll down the left-hand navigation sidebar and click on Keyboard. In the main right-hand panel, locate the “Text Input” section and click the Edit… button next to “Input Sources.” A new dialogue box will appear containing a list of your installed layouts on the left and various settings on the right. Look for the toggle switch labelled Automatically switch to a document’s input source. Click this toggle switch to turn it Off. Click Done to save. From now on, if you manually switch your keyboard to Spanish, it will stay in Spanish across every application until you explicitly change it back.