Class: Yeah::Keyboard

Inherits:
Object
  • Object
show all
Defined in:
lib/yeah/_platform/keyboard.rb

Overview

Note:

Provided by a Platform.

The Keyboard provides keyboard input handling.

Examples:

Playing sound on key press within game

neigh.play if keyboard.pressed? :scroll_lock

Constant Summary collapse

KEYS =
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, :a, :alt, :b, :backquote, :backslash,
:backspace, :c, :caps_lock, :comma, :ctrl, :d, :delete, :dot, :down,
:e, :end, :enter, :equals, :escape, :f, :f1, :f10, :f11, :f12, :f2,
:f3, :f4, :f5, :f6, :f7, :f8, :f9, :g, :h, :home, :i, :insert, :j,
:k, :l, :left, :left_bracket, :m, :minus, :n, :num0, :num1, :num2,
:num3, :num4, :num5, :num6, :num7, :num8, :num9, :num_asterisk,
:num_dot, :num_lock, :num_minus, :num_plus, :num_slash,
:o, :p, :page_down, :page_up, :pause, :q, :quote, :r, :right,
:right_bracket, :s, :scroll_lock, :semicolon, :shift, :slash, :space,
:super, :t, :tab, :u, :up, :v, :w, :x, :y, :z]

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Keyboard

Returns a new instance of Keyboard

Parameters:

  • options (Hash) (defaults to: {})

    for new object

Options Hash (options):

  • :ticker (Ticker)

    for one-shot input handling

Raises:

  • (NotImplementedError)

21
22
23
# File 'lib/yeah/_platform/keyboard.rb', line 21

def initialize(options = {})
  raise NotImplementedError
end

Instance Method Details

#pressed?(key) ⇒ true, false

Returns whether key was just pressed

Parameters:

  • key (Symbol, Integer)

    to check

Returns:

  • (true, false)

    whether key was just pressed


# File 'lib/yeah/_platform/keyboard.rb', line 29

#pressing?(key) ⇒ true, false

Returns whether key is pressed

Parameters:

  • key (Symbol, Integer)

    to check

Returns:

  • (true, false)

    whether key is pressed


# File 'lib/yeah/_platform/keyboard.rb', line 25

#released?(key) ⇒ true, false

Returns whether key was just released

Parameters:

  • key (Symbol, Integer)

    to check

Returns:

  • (true, false)

    whether key was just released


# File 'lib/yeah/_platform/keyboard.rb', line 33