grafana/k6 · error
sending key up
Error message
sending key up: %w
What it means
Wrap of Keyboard.up in the public Keyboard.Up: releases a previously pressed key by dispatching a CDP keyUp event. The wrap covers the inner failure — the key is not valid for the active layout, or the CDP Input.dispatchKeyEvent call failed due to a closed session or canceled context. Releasing a key that was never pressed is tolerated (the modifiers map is simply cleaned).
Solutions
- Use the same standard key names accepted by the layout
- Ensure key up calls happen while the session is still alive — avoid async gaps after page close
- Always pair down() with up() or use press() which handles both atomically
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at internal/js/modules/k6/browser/common/keyboard.go:64 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/430824204cfb978c.
Report an issue: GitHub.
Appendix: source
Thrown at internal/js/modules/k6/browser/common/keyboard.go:64
session: s,
pressedKeys: make(map[int64]struct{}),
layoutName: "us",
layout: keyboardlayout.GetKeyboardLayout("us"),
}
}
// Down sends a key down message to a session target.
func (k *Keyboard) Down(key string) error {
if err := k.down(key); err != nil {
return fmt.Errorf("sending key down: %w", err)
}
return nil
}
// Up sends a key up message to a session target.
func (k *Keyboard) Up(key string) error {
if err := k.up(key); err != nil {
return fmt.Errorf("sending key up: %w", err)
}
return nil
}
// Press sends a key press message to a session target.
// It delays the action if `Delay` option is specified.
// A press message consists of successive key down and up messages.
func (k *Keyboard) Press(key string, kbdOpts KeyboardOptions) error {
if err := k.comboPress(key, kbdOpts); err != nil {
return fmt.Errorf("pressing key: %w", err)
}
return nil
}
// InsertText inserts a text without dispatching key events.
func (k *Keyboard) InsertText(text string) error {
if err := k.insertText(text); err != nil {View on GitHub (pinned to 01ffac6f24)