Skip to content

Conversation

@halx99
Copy link
Collaborator

@halx99 halx99 commented Sep 14, 2025

Describe your changes

With this PR, user have chance to check whether key press event is repeat.

auto onKeyPressed = [this](ax::EventKeyboard::KeyCode code, ax::Event* e) -> void {
  if(!static_cast<EventKeyboard*>(e)->isRepeat()) {
      // one shot
  }
  else { 
      // repeat shot
  }
}

Issue ticket number and link

Checklist before requesting a review

For each PR

  • Add Copyright if it missed:
    - "Copyright (c) 2019-present Axmol Engine contributors (see AUTHORS.md)."

  • I have performed a self-review of my code.

    Optional:

    • I have checked readme and add important infos to this PR.
    • I have added/adapted some tests too.

For core/new feature PR

  • I have checked readme and add important infos to this PR.
  • I have added thorough tests.

Axmol 3.x ------------------------------------------------------------

For each 3.x PR

  • Check the '#include "axmol.h"' and replace it with the needed headers.

- Added KeyAction enum with RELEASE, PRESS, and REPEAT states
- Updated EventKeyboard constructor to take an int action instead of bool isPressed
- Added isPress() and isRepeat() helper methods for easier state checks
- Replaced _isPressed member with _action to support repeat key events
@halx99 halx99 changed the base branch from dev to release/2.x September 14, 2025 09:16
@halx99 halx99 added this to the 2.8.2 milestone Sep 14, 2025
@halx99 halx99 added the enhancement New feature or request label Sep 14, 2025
@halx99 halx99 changed the title Refactor keyboard event Add new API EventKeyboard::isRepeat Sep 14, 2025
@halx99 halx99 merged commit ac8e144 into release/2.x Sep 14, 2025
15 checks passed
@halx99 halx99 deleted the refactor-keyboard-event branch September 14, 2025 12:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants