Hi Vishnu2021,
Thanks for reaching out to Apple Support Communities. It sounds like you're having an issue with the keyboard on your MacBook Air. We're happy to assist.
We'd recommend starting with the Guide here: Set how quickly a key repeats on Mac As the issue is intermittent you can adjust the settings and test.
We also recommend checking the keyboard in the section "If other keys don’t work" from the guide here: If your Mac doesn’t respond to key presses
Which states:
You may have accidentally set an option that changes how your keyboard operates.
- Choose Apple menu > System Preferences, click Accessibility, click Keyboard, then click Hardware. Make sure Slow Keys is turned off. If Slow Keys is on, you must press and hold a key longer than usual before it’s recognized.
- Choose Apple menu > System Preferences, click Accessibility, click Pointer Control, then click Alternate Control Methods. Make sure Mouse Keys is off.
- Choose Apple menu > System Preferences, click Keyboard, then click Input Sources. Select “Show Input menu in menu bar.” Open the Input menu, then make sure the correct keyboard layout is selected."
We'd also recommend cleaning the keyboard. If needed, the steps here can assist: How to clean your Apple products
If you feel there's a hardware issue you can run a diagnostic with these steps here: Use Apple Diagnostics to test your Mac
Best!