Keyboard does not work intermittently

My keyboard sometimes works well and sometimes doesn’t. In the lock and login page, my keyboard must not work, and there is a probability that it will work again after entering the desktop. This phenomenon is like the keyboard driver failure, but I can’t be sure. I am using a new installation of version 22.10, and the system only has the NVIDIA graphics card driver installed. The system is installed on a Lenovo laptop.

unusual issue.

If this is a laptop do you have access to a USB keyboard?

Do check that other ports - sometimes plugging into a USB 3 port for a USB 1.1/2 keyboard occasionally causes issues.

An unusual question indeed. The USB keyboard is usable, but the laptop’s own keyboard is hit and miss. The failure of the notebook keyboard does not seem to be related to the external keyboard, because the notebook keyboard still fails without the external keyboard.
The current discovery is that the keyboard problem will appear when the system is restarted or the notebook is closed and opened again. This problem does not occur when the notebook enters the locked state naturally. There is a high probability that the problem will disappear within 5-10 minutes after the system restarts, but if the screen is closed and then turned on, the problem will not disappear naturally unless the notebook is restarted.

To confirm that it isn’t a hardware issue - please backup what you need and install with a 20.04.5 or a 22.04.1 image - this will be an older kernel with older but more stable libinput software which is the software that interfaces with the kernel.

That will enable to see if this is a software or possibly a hardware issue.

Its also worth having a look at the logs to see if there are any related hardware issues during boot to to the login screen - so if you see that the keyboard is misbehaving - plugin a USB keyboard and then switch to a TTY (CTRL + ALT + F3) and run

journalctl -ae --full

Scroll back to have a look at likely candidate issues.