API Docs for: 1.4.0
Show:

Kiwi.Input.Key Class

Defined in: src\input\Key.ts:10
Module: Input
Parent Module: Kiwi

A compact object that holds the most important details about a Keyboard Event response.

Constructor

Kiwi.Input.Key

(
  • manager
  • keycode
  • [event]
)
Kiwi.Input.Key

Defined in src\input\Key.ts:10

Parameters:

  • manager Kiwi.Input.Keyboard

    The keyboard manager that this key belongs to.

  • keycode Number

    The keycode that this key is.

  • [event] KeyboardEvent optional

    The keyboard event (if there was one) when this was created.

Returns:

Kiwi.Input.Key:

This object.

Methods

justPressed

(
  • [duration]
)
Boolean public

Returns a boolean indicating whether or not this key was just pressed.

Parameters:

  • [duration] Number optional

    The duration at which determines if a key was just pressed. Defaults to the managers just pressed rate.

Returns:

Boolean:

justReleased

(
  • [duration]
)
Boolean public

Returns a boolean indicating whether or not this key was just released.

Parameters:

  • [duration] Number optional

    The duration at which determines if a key was just released. Defaults to the managers just pressed rate.

Returns:

Boolean:

objType

() String public

Defined in src\input\Key.ts:55

The type of object that this is.

Returns:

String:

"Key"

reset

() public

Resets all of the properties on the Key to their default values.

update

(
  • event
)
public

The 'update' method fires when an event occur's. Updates the keys properties

Parameters:

  • event KeyboardEvent

Properties

_manager

Kiwi.Input.Keyboard private

Defined in src\input\Key.ts:65

The keyboard manager that this key belongs to.

altKey

Boolean public

Defined in src\input\Key.ts:99

If the alt key was held at the time of the event happening.

Default: false

ctrlKey

Boolean public

If the ctrl key was held at the time of the event happening.

Default: false

duration

Number public

The duration (in milliseconds) that the key has been down for. This is property is READ ONLY.

Default: 0

game

Kiwi.Game public

Defined in src\input\Key.ts:47

The game that this key belongs to.

isDown

Boolean public

Defined in src\input\Key.ts:81

Indicated whether or not the key is currently down.

Default: false

isUp

Boolean public

Defined in src\input\Key.ts:90

Indicates whether or not the key is currently up.

Default: true

keyCode

Number public

Defined in src\input\Key.ts:73

The keycode that this key is.

preventDefault

Boolean public

Defined in src\input\Key.ts:36

If the default action for this Key should be prevented or not. For example. If your game use's the spacebar you would want its default action (which is to make the website scrolldown) prevented, So you can set this to true.

Default: false

repeats

Number public

If this key is being 'held' down, this property will indicate the amount of times the 'onkeydown' event has fired. This is reset each time the key is pressed.

Default: 0

shiftKey

Boolean public

If the shift key was held at the time of the event happening.

Default: false

timeDown

Number public

The time that the key was pressed initially.

Default: 0

timeUp

Number public

The time at which the key was released.

Default: 0