Repository navigation
Text Input
using static ODDGames.BugpunchSdk.ActionExecutor;Enter text into input fields and simulate keyboard input.
Replace the text of an input field:
// Using the adjacent label (recommended for forms)
await TextInput(Adjacent("Username:"), "testuser");
await TextInput(Adjacent("Password:"), "secret123");
// Using the element name
await TextInput(Name("SearchField"), "search query");
// Press Enter afterwards (submits the field)
await TextInput(Adjacent("Message:"), "Hello world", pressEnter: true);- Finds a
TMP_InputFieldor legacyInputFieldon the matched element, its children or its parents - Clicks the field to focus it
- Sets the field's text (existing text is replaced) and moves the caret to the end
- Optionally presses Enter
TMP_InputField reads keystrokes through IMGUI rather than the Input System, so the text is assigned directly instead of being typed character by character. onValueChanged still fires; per-keystroke validation does not run.
| Parameter | Type | Default | Description |
|---|---|---|---|
search |
Search | required | How to find the input field |
input |
string | required | Text to enter |
seconds |
float | 10 |
Seconds to wait for the field |
pressEnter |
bool | false |
Press Enter after setting the text |
Type is the lower-level variant: it targets the matched element itself (the component must be on that GameObject), and can append instead of replacing:
// Replace (default)
await Type(Name("UsernameInput"), "player1");
// Append to what's already there
await Type(Name("ChatInput"), " and more", clearFirst: false);
// Submit
await Type(Name("SearchInput"), "search term", pressEnter: true);Signature: Type(Search search, string text, bool clearFirst = true, bool pressEnter = false, float searchTime = -1f, int index = 0).
Best for form fields with labels:
await TextInput(Adjacent("Email:"), "user@example.com");
await TextInput(Adjacent("Phone*"), "555-1234");When the input field has a unique name:
await TextInput(Name("UsernameInput"), "player1");
await TextInput(Name("ChatInput"), "Hello!");Find the first available input:
await TextInput(Type<TMP_InputField>(), "test");Keyboard actions inject real key events on a virtual Input System keyboard. They need using UnityEngine.InputSystem; when you use the Key enum.
Press and release a single key:
using UnityEngine.InputSystem;
// By Input System Key
await PressKey(Key.Escape);
// By KeyCode
await PressKey(KeyCode.Space);
await PressKey(KeyCode.Return);
// By character
await PressKey('a');
// By name: any KeyCode name, or enter / esc / up / down / left / right / backspace / del
await PressKey("enter");
await PressKey("Tab");Press one key per character of a string:
await PressKeys("hello world");This doesn't focus anything first and doesn't add Shift for capitals or symbols — it's for driving key bindings, not filling text fields. Use TextInput / Type for fields.
Queue Input System text events (one character per frame) to whatever currently has keyboard focus:
await TypeText("typed via text events");Useful for UI that listens to Keyboard.onTextInput. TMP_InputField ignores these events, so use TextInput for it.
Hold one or more keys down together for a duration:
using UnityEngine.InputSystem;
// Move forward for 2 seconds
await HoldKey(Key.W, 2f);
// Sprint: hold W and Shift together
await HoldKeys(1.5f, Key.W, Key.LeftShift);
// KeyCode overloads too
await HoldKey(KeyCode.Space, 0.5f);await TextInput(Adjacent("Username:"), "testuser");
await TextInput(Adjacent("Password:"), "password123");
await Click(Text("Login"));await TextInput(Adjacent("First Name:"), "John");
await TextInput(Adjacent("Last Name:"), "Doe");
await TextInput(Adjacent("Email:"), "john.doe@example.com");
await TextInput(Adjacent("Password:"), "SecurePass123!");
await TextInput(Adjacent("Confirm Password:"), "SecurePass123!");
await Click(Text("Register"));await TextInput(Name("SearchInput"), "search term", pressEnter: true);Hold the modifier and the key together:
using UnityEngine.InputSystem;
// Ctrl+S
await HoldKeys(0.1f, Key.LeftCtrl, Key.S);await PressKey(KeyCode.W); // Step forward
await PressKey(KeyCode.Space); // Jump
await PressKey(KeyCode.Escape); // Pause menu-
UnityEngine.UI.InputField(Legacy) -
TMPro.TMP_InputField(TextMeshPro)
Basic Filters
Proximity
Hierarchy
Spatial
Ordering
Modifiers
Combining
Reflection
- Test Actions
- Click Actions
- Text Input
- Drag Actions
- Gesture Input
- Wait and Find
- Assertions
- GameObject Manipulation