# Input

The `Scar::Input` class is an input manager. It supports digital and analog inputs from arbitrary sources. It does not really query inputs itself, it is rather a wrapper where you can define some input method and check it easily via a symbol instead of having to call sfml or native methods.

An instance of it has to be passed to your app because you might want to subclass and add some other functionality to it or have separate input managers for multiple windows.&#x20;

You define an input via the `Input#bind_digital` or `Input#bind_axis` functions. Both receive a symbol and a block as arguments. The symbol is the identifier for querying the input. The block should return if the input is active for digital inputs and a float value for analog axis inputs. You may define multiple digital input handlers for one symbol.&#x20;

{% hint style="info" %}
For simple keyboard inputs, you can use the `Input#sf_key` macro to query if that key is currently pressed. `Input.bind_digital(:example) { Input.sf_key(:Space) }`
{% endhint %}

To query the input, you use the `Input#active?`(digital) and `Input#axis` methods.

```ruby
# in app#init

@input.bind_digital(:example) { Input.sf_key(:Space) }
# you can add any kind of digital check here if you want
@input.bind_digital(:even_second) { Time.now.second % 2 == 0 }

# in some update
puts "even second!" if app.input.active? :even_second
```
