grafana/k6 · error

cannot do key down

Error message

cannot do key down: %w

What it means

Wrap of Keyboard.down inside Keyboard.comboPress: for a compound key string like 'Control+A', each key is pressed in order before any is released. This wrap means one of the down presses failed — most often the first key component is an invalid layout key (e.g., typo in 'Cntrl'), or the CDP dispatch failed on a dead session before the combo completed.

Solutions

  1. Check every component of the combo string for valid, correctly-cased key names
  2. Keep the session alive for the full combo duration
  3. Use press('Control+A') instead of manual down/up orchestration
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at internal/js/modules/k6/browser/common/keyboard.go:270 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of grafana/k6@01ffac6f24 (2026-08-18). Data as JSON: /api/errors/a657aaa724bd4a0f. Report an issue: GitHub.

Appendix: source

Thrown at internal/js/modules/k6/browser/common/keyboard.go:270

			key = "Meta"
		} else {
			key = "Control"
		}
	}
	return key
}

func (k *Keyboard) comboPress(keys string, opts KeyboardOptions) error {
	if opts.Delay > 0 {
		if err := wait(k.ctx, opts.Delay); err != nil {
			return err
		}
	}

	kk := split(keys)
	for _, key := range kk {
		if err := k.down(key); err != nil {
			return fmt.Errorf("cannot do key down: %w", err)
		}
	}

	for i := range kk {
		key := kk[len(kk)-i-1]
		if err := k.up(key); err != nil {
			return fmt.Errorf("cannot do key up: %w", err)
		}
	}

	return nil
}

// This splits the string on `+`.
// If `+` on it's own is passed, it will return ["+"].
// If `++` is passed in, it will return ["+", ""].
// If `+++` is passed in, it will return ["+", "+"].
func split(keys string) []string {

View on GitHub (pinned to 01ffac6f24)