mirror of
https://github.com/SleepingInsomniac/pixelfaucet
synced 2025-01-31 19:57:53 +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)
|
def pressed?(name)
|
||||||
return false if @keysdown[name] & READ != 0
|
return false if @keysdown[name] & READ != 0
|
||||||
return false unless @keysdown[name] & PRESSED != 0
|
return false unless @keysdown[name] & PRESSED != 0
|
||||||
|
@ -75,11 +80,13 @@ module PF
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
def action?(name)
|
# Returns true if a registered button is being held
|
||||||
|
def held?(name)
|
||||||
@keysdown[name] & PRESSED > 0
|
@keysdown[name] & PRESSED > 0
|
||||||
end
|
end
|
||||||
|
|
||||||
def held?(name)
|
# ditto
|
||||||
|
def action?(name)
|
||||||
@keysdown[name] & PRESSED > 0
|
@keysdown[name] & PRESSED > 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue