Class «keys»

This article is automatically translated from Russian by Google Translator.

Used to operate the buttons on the robot's remote control.

Method

Description

Sent when the button with the specified code is pressed or released.

Returns true if the button with the specified code is currently pressed.

Сбрасывает запомненные нажатия кнопок.

Returns whether or not a button with the specified code was pressed, reset the remembered presses for that button.

buttonPressed

Sent when the button with the specified code is pressed or released.

Syntax

brick.keys().buttonPressed.connect(function(code, value){if (code==KeysEnum.Up)brick.stop() ; });

The first parameter is the code of the button, the second - 1 if the button is pressed, 0 if released.

isPressed

Returns true if the button with the specified code is currently pressed. Possible options:

  • KeysEnum.Left (code105),

  • KeysEnum.Up (code 103),

  • KeysEnum.Down (code 108),

  • KeysEnum.Enter (code 28),

  • KeysEnum.Right (code 106),

  • KeysEnum.Power (code 116),

  • KeysEnum.Esc (code 1).

Syntax

brick.keys().isPressed(KeysEnum.Up);

reset

Resets memorized button presses.

Syntax

brick.keys().reset();

wasPressed

Returns whether or not a button with the specified code was pressed, reset the remembered presses for that button. Possible options:

  • KeysEnum.Left (code 105),

  • KeysEnum.Up (code 103),

  • KeysEnum.Down (code 108),

  • KeysEnum.Enter (code 28),

  • KeysEnum.Right (code 106),

  • KeysEnum.Power (code 116),

  • KeysEnum.Esc (code 1).

Syntax

brick.keys().wasPressed(KeysEnum.Up);

Last updated