prefab-user-properties-keycode-type.rst 782 B

12345678910111213141516171819202122232425262728293031
  1. .. include:: ../_header.rst
  2. Key Code property type
  3. ```````````````````````
  4. This type of property allows selecting one of the key codes available in the ``Phaser.Input.Keyboard.KeyCodes`` class:
  5. .. image:: ../images/prefab-user-props-keycode-1-20230627.webp
  6. :alt: KeyCode property.
  7. .. image:: ../images/prefab-user-props-keycode-2-20230627.webp
  8. :alt: KeyCode dialog.
  9. You can use properties of this type for binding the behavior of an object or a game action with a certain keyboard key.
  10. Property code generation
  11. ''''''''''''''''''''''''
  12. The |SceneCompiler|_ generates the Key Code properties like this:
  13. .. code::
  14. class Dragon extends Phaser.GameObjects.Sprite {
  15. constructor(..) {
  16. ...
  17. }
  18. private jumpKey: number = Phaser.Input.Keyboard.KeyCodes.UP;
  19. }