stride3d/stride · error · InvalidOperationException
Simulated Keyboard does not exist
Error message
Simulated Keyboard does not exist
What it means
InputSourceSimulated.RemoveKeyboard requires the KeyboardSimulated instance to be present in the source's keyboards collection. Passing an untracked or already-removed keyboard throws InvalidOperationException.
Solutions
- Only remove keyboards created by this source
- Guard against double removal with bookkeeping or membership checks
- Use RemoveAllKeyboards for batch teardown
- After removal, drop references so the instance isn't passed again
Example fix
// before source.RemoveKeyboard(keyboard); source.RemoveKeyboard(keyboard); // throws // after if (keyboards.Contains(keyboard)) source.RemoveKeyboard(keyboard);
Defensive patterns
Strategy: validation
Validate before calling
if (createdKeyboards.Contains(keyboard)) source.RemoveKeyboard(keyboard);
Try / catch
try { source.RemoveKeyboard(keyboard); } catch (InvalidOperationException) { /* already removed */ } Prevention
- Only remove keyboards created by this source instance
- Clear references after removal
- Use RemoveAllKeyboards for teardown
When it happens
Trigger: Calling RemoveKeyboard with a keyboard not created by this source's CreateKeyboard, or calling RemoveKeyboard twice on the same instance.
Common situations: Repeated test teardown; keyboards removed via RemoveAllKeyboards and then removed again individually; cross-source keyboard references.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Simulated GamePad does not exist
- Simulated Mouse does not exist
- Simulated PointerDevice does not exist
- Can not set more than one button at a time
- The given does not correspond to any existing part.
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/55b043b36a6bfb96.
Report an issue: GitHub.
Appendix: source
Thrown at sources/engine/Stride.Input/Simulated/InputSourceSimulated.cs:95
public void RemoveAllMice()
{
foreach (var mouse in mice)
UnregisterDevice(mouse);
mice.Clear();
}
public KeyboardSimulated AddKeyboard()
{
var keyboard = new KeyboardSimulated(this);
keyboards.Add(keyboard);
RegisterDevice(keyboard);
return keyboard;
}
public void RemoveKeyboard(KeyboardSimulated keyboard)
{
if (!keyboards.Contains(keyboard))
throw new InvalidOperationException("Simulated Keyboard does not exist");
UnregisterDevice(keyboard);
keyboards.Remove(keyboard);
}
public void RemoveAllKeyboards()
{
foreach (var keyboard in keyboards)
UnregisterDevice(keyboard);
keyboards.Clear();
}
public PointerSimulated AddPointer()
{
var pointer = new PointerSimulated(this);
pointers.Add(pointer);
RegisterDevice(pointer);
return pointer;
}View on GitHub (pinned to 96fad776d2)