keySequence = $keySequence; } /** * Add a key press to the sequence */ public function pressKey(string $key): self { $this->keySequence[] = $key; return $this; } /** * Add multiple key presses */ public function pressKeys(array $keys): self { foreach ($keys as $key) { $this->pressKey($key); } return $this; } /** * Add arrow up key */ public function arrowUp(): self { return $this->pressKey(self::KEY_UP); } /** * Add arrow down key */ public function arrowDown(): self { return $this->pressKey(self::KEY_DOWN); } /** * Add arrow left key */ public function arrowLeft(): self { return $this->pressKey(self::KEY_LEFT); } /** * Add arrow right key */ public function arrowRight(): self { return $this->pressKey(self::KEY_RIGHT); } /** * Add enter key */ public function enter(): self { return $this->pressKey(self::KEY_ENTER); } /** * Add escape key */ public function escape(): self { return $this->pressKey(self::KEY_ESCAPE); } /** * Add tab key */ public function tab(): self { return $this->pressKey(self::KEY_TAB); } /** * Get next key in sequence */ public function getNextKey(): ?string { if ($this->currentIndex >= count($this->keySequence)) { return null; } $key = $this->keySequence[$this->currentIndex]; $this->currentIndex++; return $key; } /** * Reset to beginning */ public function reset(): void { $this->currentIndex = 0; } /** * Check if there are more keys */ public function hasMoreKeys(): bool { return $this->currentIndex < count($this->keySequence); } /** * Get all remaining keys */ public function getRemainingKeys(): array { return array_slice($this->keySequence, $this->currentIndex); } /** * Get the full sequence */ public function getSequence(): array { return $this->keySequence; } }