As the Windows keyboard layout is different from that of a Mac, using a Windows keyboard with your Mac can result in frustration, with missed or incorrect key presses. Most mechanical keyboards are not available with a Mac layout, so many people need to find ways to improve the compatibility with macOS. There are exceptions, such as the excellent keyboards from Das Keyboards or Keychron.
If you also use a Windows PC, such as a separate Gaming PC or a work laptop, it is easier and preferable to keep a consistent layout between the devices, rather than having to mentally relearn each time you swap between devices.
You may have simply purchased a new keyboard for your Mac with a Windows layout. In this case, you may want to change the keyboard behaviour so that it functions the same as a Mac keyboard, even if the keycap labels are not the same. When you plug a Windows keyboard into a Mac you will find that the Command key will now be the Windows key rather than the key closest to the space bar. Changing this will bring back the familiar Mac layout. It is possible to change the functionality of the keys in the Mac System Preferences, allowing you to change the behaviour of the modifier keys, such as Control, Option (Alt), Caps Lock and Command.
If your keyboard has removable keycaps, you can swap them over, such as swapping the Alt and Windows keys to make it look 'closer' to a Mac. However some Mac users may still take offence at the Windows key; however, I look at this as a great opportunity to improve your touch typing!
macOS Modifier Key Mapping
To start, open the System Preferences and select Keyboard.
Towards the bottom right is the Modifier Keys… button. Select this to open the modifier keys configuration.
If not already shown, select your attached keyboard from the dropdown. In the screenshot, my GMMK mechanical keyboard is listed as USB Device. The dropdown also includes any USB mice you have connected, so ensure you select the correct device. For some strange reason, it is also possible to set the modifier keys for a mouse!
What modifier key changes you make are a personal preference. For my mechanical keyboard, as I have swapped over the Alt and Windows keycaps, I also decided to swap over their functions. This is my recommendation if you have a mechanical keyboard, where keycaps can typically be removed.
For each modifier key on the left, you specify the actual key on the keyboard to use for that modifier. This took me a while to get my head around, but the key on the left is the actual key on the keyboard, and the dropdown is the action you want to perform when that key is pressed.
For example, to remap the Command key to the first key either side of the keyboard (as per the standard Mac layout), you need to select the key that you will be pressing on the keyboard, typically the Alt key of a Windows keyboard. Select the dropdown next to the Option Key, and then select Command. This means that when you press the Alt key on the keyboard, macOS will interpret this as the Command key. Note the Alt key on a windows keyboard is also labelled Option on a Mac. As you have remapped the option key, you now need to remap the Command key, therefore select Option from the dropdown next to the Command Key.
This effectively reverses the keys, so pressing the Alt key will now be the same as pressing the Command Key.
Whilst it is not always possible to swap over the keycaps, this shows a quick way to replicate the Mac keyboard layout without having to relearn where the keys are. Also, touch typists will worry less about the key labels being incorrect.