Improved state handling with key input delegation