Porting Keycode stuff to Swift.