Hello MisterEdF,
Thank you for posting to the Apple Support Communities.
If a connection issue is happening or certain keys are not responding on your Magic Keyboard, please be sure that the keyboard is fully charged first: Charge a Magic Keyboard, Magic Mouse 2, or Magic Trackpad 2 with Mac.
You can also find additional troubleshooting steps in the following Apple Support article: If you can't connect your Magic Keyboard, Magic Mouse, or Magic Trackpad to your Mac. This article explains how to make sure the Bluetooth connection is solid, or how to pair the keyboard again using a cable.
An issue like this could also be caused by wireless interference. This last article explains how you can identify and remove any sources of wireless interference near your Mac and keyboard: Resolve Wi-Fi and Bluetooth issues caused by wireless interference.
Please reply back here if you have any additional questions or need more help.
Have a great day!