improved key handling.