Welcome Priiyanka,
Thank you for reaching out to Microsoft Q&A.
I understand that your computer automatically locks whenever you press the “L” key. This may happen if the Windows key is stuck or being registered as pressed.
To help narrow down the issue, could you please confirm:
- Are you using Windows 10 or Windows 11?
- Does the computer lock when you press “L” in all applications, including Notepad?
- Are you using a laptop's built-in keyboard or an external keyboard?
In the meantime, please try this test:
- Open Settings > Accessibility > Keyboard
- Turn on On-Screen Keyboard
- Press the L key on your physical keyboard and check whether the Windows key appears highlighted on the on-screen keyboard.
Looking forward to your update.