Skip to content

inpututil.IsKeyJustReleased returns true for two consecutive frames #3326

@intrugli

Description

@intrugli

Ebitengine Version

2.9

Operating System

  • Windows
  • macOS
  • Linux
  • FreeBSD
  • OpenBSD
  • Android
  • iOS
  • Nintendo Switch
  • PlayStation 5
  • Xbox
  • Web Browsers

Go Version (go version)

1.24.7

What steps will reproduce the problem?

package main

import (
	"github.com/hajimehoshi/ebiten/v2"
	"github.com/hajimehoshi/ebiten/v2/inpututil"
)

type Game struct {
}

func (g *Game) Update() error {

	if inpututil.IsKeyJustReleased(ebiten.KeyA) {
		println("key A", ebiten.Tick())
	}

	return nil

}

func (g *Game) Draw(screen *ebiten.Image) {
}

func (g *Game) Layout(outsideWidth, outsideHeight int) (int, int) {
	return 320, 180
}

func main() {
	if err := ebiten.RunGame(&Game{}); err != nil {
		panic(err)
	}
}

What is the expected result?

This output on the console:

key A 70

What happens instead?

This output on the console:

key A 70
key A 71

Anything else you feel useful to add?

This happens on Linux 100% on the time with a physical or virtual keyboard.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions