Please do try these troubleshooting steps that may help.
- First is to uninstall/reinstall the keyboard driver.
- Go to Device Manager and uninstall the keyboard driver then reboot the laptop.
- After the reboot do test it again and see if it will work or not.
- And lastly, try connecting an external USB keyboard and see if everything will work normal using it.
- If it will work just fine I would also consider reinstalling Windows.
- Replacing the whole keyboard would be the only solution if all these will not work.
- Before considering on replacing the keyboard, do check the ribbon cable that connects the keyboard to the motherboard first if its loose or not. Try to disconnect the cable then reconnect it.