If you have another device... open the directions found here: https://support.apple.com/en-us/HT201295
If that does not work... It sounds weird but doing a PRAM reset to follow will kick out most cobwebs and get things running again. Do that by holding opt + command + P + R at the same time at start up (before chime)... Keep holding...the screen will blacken again... then release once you hear the chime for the second time.
If this fails, or the issue repeats... Follow the steps found here: https://support.apple.com/en-us/HT201257
Spoiler alert on the last one... it's boot up your computer holding the D key until you see the AHT icon pop up. You should be able to easily follow the steps in the prompts to walk you though testing your hardware. Make sure any peripherals are disconnected when running this test.
You may end up having to replace the keyboard at some point... but first start with a simple SMC reset... then PRAM... then the AHT.