I've seen some similar reports recently, but not enough details to determine the cause although I'm beginning to suspect a macOS bug.
I have personally seen something similar with a couple of my organization's Macs when trying to login from the lock screen, however, each time it occurred with a clean install of macOS 14.x Sonoma usually after the first boot into the new OS before having rebooted the new OS. In each of those instances I had to force a power off. When the Mac rebooted, everything worked as it should.
Try using an external keyboard to see if that makes a difference. Otherwise you will need to force a power off, then power computer back on.
Make sure macOS is fully up to date with all the latest update patches.
FYI, when asking for assistance online, it is usually recommended to provide the exact model of your Mac and the exact version of macOS being used. You can get this information by clicking the Apple menu and selecting "About This Mac", however, if your Mac is not able to boot or log in, then you can get the exact model by entering the system serial number on the Apple check coverage page here:
Check Your Service and Support Coverage - Apple Support