Handle keyboard events for nested dialogs properly