mirror of
https://github.com/SleepingInsomniac/pixelfaucet
synced 2025-01-18 22:26:32 +01:00
Add method to check if any key is pressed
This commit is contained in:
parent
829ee59c54
commit
acff191dab
1 changed files with 9 additions and 2 deletions
|
@ -68,6 +68,11 @@ module PF
|
|||
|
||||
# ===============
|
||||
|
||||
def any_pressed?
|
||||
@keysdown.any? { |name, state| state & PRESSED > 0 }
|
||||
end
|
||||
|
||||
# Returns true the first time called if a button has been pressed
|
||||
def pressed?(name)
|
||||
return false if @keysdown[name] & READ != 0
|
||||
return false unless @keysdown[name] & PRESSED != 0
|
||||
|
@ -75,12 +80,14 @@ module PF
|
|||
true
|
||||
end
|
||||
|
||||
def action?(name)
|
||||
@keysdown[name] & PRESSED > 0
|
||||
end
|
||||
|
||||
# Returns true if a registered button is being held
|
||||
def held?(name)
|
||||
@keysdown[name] & PRESSED > 0
|
||||
end
|
||||
|
||||
# ditto
|
||||
def action?(name)
|
||||
@keysdown[name] & PRESSED > 0
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue