Add input direction detection.