Skip to content

Commit

Permalink
Add isKeyPressed()
Browse files Browse the repository at this point in the history
  • Loading branch information
sago35 committed Jan 26, 2025
1 parent e8e862a commit ae643d7
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions inpututil.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ const (
KeyDown
)

const (
KeyArrowLeft = KeyLeft
KeyArrowRight = KeyRight
KeyArrowUp = KeyUp
KeyArrowDown = KeyDown
)

type pos struct {
x int
y int
Expand Down Expand Up @@ -160,6 +167,10 @@ func IsKeyJustPressed(key Key) bool {
return KeyPressDuration(key) == 1
}

func IsKeyPressed(key Key) bool {
return KeyPressDuration(key) > 0
}

// IsKeyJustReleased returns a boolean value indicating
// whether the given key is released just in the current tick.
//
Expand Down

0 comments on commit ae643d7

Please sign in to comment.