Make key handling work for non-ASCII characters