I've looked around, does anyone know if KeyboardState.GetPressedKeys()
(in Microsoft.Xna.Framework.Input
) returns the keys in an organised collection (most recent first or last in the list) or some disorganised unpredictable list?

- 1,040
- 1
- 12
- 19

- 71
- 6
-
Logical wise it would be recent one first. (as in recently added), can you attempt to debug it? – Steven Feb 07 '19 at 16:05
-
I'll try debug it and discover, just working on some UI stuff atm. – ClownFishUK Feb 08 '19 at 04:42
1 Answers
The order of the array is defined by platform's keycode code order.
You cannot determine pressed order using this, or any other MonoGame method, since the system is only queried for currently pressed keycodes, every game loop iteration.
At the default frame rate of 60 fps for Windows games, this equates to 16 milliseconds, the order of key presses becomes somewhat irrelevant. Attempting to make sense of the mashing of keys is nonsensical, unless the goal is to find which key is first pressed (as a "Jeopardy" style button). If that is the case, a hook into the OS will provide the best resolution (up to 240 samples per second on Windows).
The order is always consistent within a platform and keyboard layout. Please see the definition for KeyboardState.cs and Keyboard.Windows.cs.

- 1,040
- 1
- 12
- 19