This pulls in almost all of the original PR in #2235. I skipped a dead key case that I recall being tricky: I didn't want to break the non win32-input mode version of that. I'd be happy to have that case re-evaluated in a smaller PR where we can focus on its details. Co-authored-by: Dominik Kreutzer <kreudom@gmail.com>