Hi Elisabeth,
I am Sumit here to assist you with this question.
Usually if the keyboard is connected, the screen lock button would grey out. This is by design.
Nevertheless, see if reinstalling the sensor helps:
Press Windows+R keys on the keyboard, or Right-click Start on the Taskbar and choose Run.
Type devmgmt.msc
Press Enter.
Look for Sensors tab, there should be your accelerometer.
Right-click it and uninstall the driver. At the top of the Device Manager, select Action and click scan for hardware changes to reinstall the driver.
Keep me posted and good luck.