Key handling. Still doesn't work right.