Skip to main content

Keyboard

Description:

  Provides an interface to the user's keyboard.

setKeyRepeat

Type: Function.

Description:

  Enables or disables key repeat for love.keypressed. It is disabled by default. Overload details:

  1. The interval between repeats depends on the user's system settings. This function doesn't affect whether love.textinput is called multiple times while a key is held down.

Signature:

setKeyRepeat: function(enabled: boolean)

Parameters:

ParameterTypeDescription
enabledbooleanWhether repeat keypress events should be enabled when a key is held down.

hasKeyRepeat

Type: Function.

Description:

  Gets whether key repeat is enabled.

Signature:

hasKeyRepeat: function(): boolean

Returns:

Return TypeDescription
booleanWhether key repeat is enabled.

isDown

Type: Function.

Description:

  Checks whether a certain key is down. Not to be confused with love.keypressed or love.keyreleased.

Signature:

isDown: function(keys: string...): boolean

Parameters:

ParameterTypeDescription
keysstring...A table containing keys to check.

Returns:

Return TypeDescription
booleandown — True if the key is down, false if not.

isDown

Type: Function.

Description:

  Checks whether a certain key is down. Not to be confused with love.keypressed or love.keyreleased.

Signature:

isDown: function(keys: {string}): boolean

Parameters:

ParameterTypeDescription
keys{string}A table containing keys to check.

Returns:

Return TypeDescription
booleandown — True if the key is down, false if not.

isScancodeDown

Type: Function.

Description:

  Checks whether the specified Scancodes are pressed. Not to be confused with love.keypressed or love.keyreleased.

-- Unlike regular KeyConstants, Scancodes are keyboard layout-independent. The scancode 'w' is used if the key in the same place as the 'w' key on an American keyboard is pressed, no matter what the key is labelled or what the user's operating system settings are.

Signature:

isScancodeDown: function(scancodes: string...): boolean

Parameters:

ParameterTypeDescription
scancodesstring...A Scancode to check.

Returns:

Return TypeDescription
booleandown — True if any supplied Scancode is down, false if not.

isScancodeDown

Type: Function.

Description:

  Checks whether the specified Scancodes are pressed. Not to be confused with love.keypressed or love.keyreleased.

-- Unlike regular KeyConstants, Scancodes are keyboard layout-independent. The scancode 'w' is used if the key in the same place as the 'w' key on an American keyboard is pressed, no matter what the key is labelled or what the user's operating system settings are.

Signature:

isScancodeDown: function(scancodes: {string}): boolean

Parameters:

ParameterTypeDescription
scancodes{string}A Scancode to check.

Returns:

Return TypeDescription
booleandown — True if any supplied Scancode is down, false if not.

getScancodeFromKey

Type: Function.

Description:

  Gets the hardware scancode corresponding to the given key. Unlike key constants, Scancodes are keyboard layout-independent. For example the scancode 'w' will be generated if the key in the same place as the 'w' key on an American keyboard is pressed, no matter what the key is labelled or what the user's operating system settings are. Scancodes are useful for creating default controls that have the same physical locations on on all systems.

Signature:

getScancodeFromKey: function(key: string): string

Parameters:

ParameterTypeDescription
keystringThe key to get the scancode from.

Returns:

Return TypeDescription
stringThe scancode corresponding to the given key, or 'unknown' if the given key has no known physical representation on the current system.

getKeyFromScancode

Type: Function.

Description:

  Gets the key corresponding to the given hardware scancode. Unlike key constants, Scancodes are keyboard layout-independent. For example the scancode 'w' will be generated if the key in the same place as the 'w' key on an American keyboard is pressed, no matter what the key is labelled or what the user's operating system settings are. Scancodes are useful for creating default controls that have the same physical locations on on all systems.

Signature:

getKeyFromScancode: function(scancode: string): string

Parameters:

ParameterTypeDescription
scancodestringThe scancode to get the key from.

Returns:

Return TypeDescription
stringThe key corresponding to the given scancode, or 'unknown' if the scancode doesn't map to a KeyConstant on the current system.

setTextInput

Type: Function.

Description:

  Enables or disables text input events. It is enabled by default on Windows, Mac, and Linux, and disabled by default on iOS and Android.

-- On touch devices, this shows the system's native on-screen keyboard when it's enabled.

Signature:

setTextInput: function(enabled: boolean)

Parameters:

ParameterTypeDescription
enabledbooleanWhether text input events should be enabled.

setTextInput

Type: Function.

Description:

  Enables or disables text input events. It is enabled by default on Windows, Mac, and Linux, and disabled by default on iOS and Android.

-- On touch devices, this shows the system's native on-screen keyboard when it's enabled.

Signature:

setTextInput: function(enabled: boolean, x: number, y: number, width: number, height: number)

Parameters:

ParameterTypeDescription
enabledbooleanWhether text input events should be enabled.
xnumberText rectangle x position.
ynumberText rectangle y position.
widthnumberText rectangle width.
heightnumberText rectangle height.

hasTextInput

Type: Function.

Description:

  Gets whether text input events are enabled.

Signature:

hasTextInput: function(): boolean

Returns:

Return TypeDescription
booleanWhether text input events are enabled.

hasScreenKeyboard

Type: Function.

Description:

  Gets whether screen keyboard is supported.

Signature:

hasScreenKeyboard: function(): boolean

Returns:

Return TypeDescription
booleanWhether screen keyboard is supported.