stride3d / stride3d/stride

The KeyInput Event while a key is pressed and held are not available in the Input.KeyEvents collection.

Open
#1,975 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
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:

  1. Create new project with the "New Game" template
  2. Create a SyncScript and attach it to any entity in a scene
  3. 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");
    }
}
  1. Run the game and press + hold any keyboard key.
  2. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.