If I hold a letter, my keyboard stops working for that app I can reliably reproduce this in several programs. If I hold a letter such as a to type aaaaaaaaaaaaaaaa, it doesn't repeat, it just types it once. But then when I try to input text in the app after that it doesn't work. Keyboard shortcuts still work in the app, but input no longer works. In Chrome, input in the page fails but I can input in the address bar ok. 

What on earth could cause this and how do I fix it?

This is on a MacBook Pro 15 inch Mid 2015, OSX 10.12.2 (Sierra).

Here's a screencast of it happening:


Note how I type h a few times individually, then hit space and hold the h key. From that point on the keyboard completely fails to input any characters, though (as demonstrated) I can use the keyboard to copy/paste just fine. In Chrome, the keyboard is only broken in that tab (even through a refresh--the only way to get the keyboard back is to open a new tab). In text editors like PHPStorm, it's broken in all tabs and the entire app must be restarted to unbreak the keyboard.
I cannot reproduce the issue on my end but it sounds like you may have an issue with an Accessibility feature, seeing as how it's happening in multiple applications. Have you tried toggling 'System 
Preferences > Accessibility > Keyboard > Sticky Keys' (or Slow Keys) on and off and trying to reproduce the issue?

Second option might just be that your keyboard settings were somehow changed from the preset delays that you're used to. You could check 'System Preferences > Keyboard > Keyboard' and check the delay sliders. Setting the first one to 'Fast' and the second one to 'Short' should actually allow you to press and hold a non-alpha-numeric key for multiple entries (such as the punctuation keys or keys like =, +, -, _, etc.) 

Note: The Mac keyboard does not allow you to press and hold letters because certain letters such as 'a' and 'e' trigger an accent menu to create characters such as 'à' or 'ē'.