You don't need to switch anything in the keyboard. If you want to switch to Dvorak, you press Win+space and Windows switches the layout for you. Might be a different shortcut in other OS, but the principle is the same.
I know there are programmable keyboards, but it's just a way to overprice things. Because you can achieve the very same programmability with AutoHotKey. The only difference is that instead of having a microcontroller and the software inside the keyboard, you use a tiny fraction of your computer's resources to run that software. There is no difference, except marketing.
By the way, US keyboards usually have separate scancodes for the right Alt, even though the print is the same. And since we're using the very same keyboard module for both layouts (only different keycaps), most likely the scan codes will be the same for both of the layouts.