The KeyInput Event while a key is pressed and held are not available in the Input.KeyEvents collection.
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 7.8k
- Forks
- 1.2k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 49
Description
Release Type: Official Release
Version: Version 4.1.0.1948
Platform(s): Windows (10)
Describe the bug
The KeyInput Event while a key is pressed and held are not available in the Input.KeyEvents collection (Basically the same event with an increased RepeatCount).
To Reproduce
Steps to reproduce the behavior:
- Create new project with the "New Game" template
- Create a SyncScript and attach it to any entity in a scene
- Add the following code in the update Method
foreach (var keyInput in Input.KeyEvents)
{
if (keyInput.IsDown)
{
if (keyInput.RepeatCount == 0)
Console.WriteLine($"Key: {keyInput.Key} , IsDown: {keyInput.IsDown}, RepeatCount: {keyInput.RepeatCount} down");
else
Console.WriteLine($"Key: {keyInput.Key} , IsDown: {keyInput.IsDown}, RepeatCount: {keyInput.RepeatCount} pressed");
}
else
{
Console.WriteLine($"Key: {keyInput.Key} , IsDown: {keyInput.IsDown}, RepeatCount: {keyInput.RepeatCount} up");
}
}
- Run the game and press + hold any keyboard key.
- The key-pressed will not occur/written to console
Expected behavior
The KeyInput event with a RepeatCount greater than 0 is available after a short while when the key is being pressed and held (~300ms)
Screenshots
NA
Log and callstacks
[2023-10-21 20:21:45.2792 +02:00] [INF] [InputHandler.Update:50] KeyInput - Key: Space, IsDown: True, RepeatCount: 0 down
[2023-10-21 20:21:46.3334 +02:00] [INF] [InputHandler.Update:50] KeyInput - Key: Space, IsDown: False, RepeatCount: 0 up
[2023-10-21 20:21:47.4309 +02:00] [INF] [InputHandler.Update:50] KeyInput - Key: Space, IsDown: True, RepeatCount: 0 down
[2023-10-21 20:21:48.7975 +02:00] [INF] [InputHandler.Update:50] KeyInput - Key: Space, IsDown: False, RepeatCount: 0 up
[2023-10-21 20:21:49.8974 +02:00] [INF] [InputHandler.Update:50] KeyInput - Key: Space, IsDown: True, RepeatCount: 0 down
[2023-10-21 20:21:51.3476 +02:00] [INF] [InputHandler.Update:50] KeyInput - Key: Space, IsDown: False, RepeatCount: 0 up
Note: There should be logs with IsDown: True, RepeatCount: 1+ pressed between the down/up events.
Additional context
switching the TargetFramework in the <ProjectName>.Windows project from net6.0-windows to net6.0 seems to fix the issue (probably because the net6.0-windowsuses a different Input).
Could be related to #1791
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue in a Windows project using the New Game template and a SyncScript that reads Input.KeyEvents. Start by comparing the net6.0-windows and net6.0 targets and trace the Input.KeyEvents path; the fix should make repeated key events with increasing RepeatCount appear while a key is held, without breaking key-down and key-up events.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- game-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100