Fixed "dictionary changed size during iteration" exception.

Unfortunately, update_keyboard_mapping sometimes still doesn't correctly
re-bind keys.