Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Game Development
  4. keyPressEvent isn't called simultaneously.
Forum Update on Monday, May 27th 2025

keyPressEvent isn't called simultaneously.

Scheduled Pinned Locked Moved Unsolved Game Development
3 Posts 3 Posters 125 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    Haru
    wrote 29 days ago last edited by
    #1

    I'm developping a RPG game.

    When I push the right-key and push the up-key simultaneously, event loop stops.

    Why?

    bool MapScene::event(QEvent *event)
    {
    if (event->type() == QEvent::KeyPress)
    {
    qDebug() << "event";
    }

    return QGraphicsScene::event(event);
    

    }

    I tried at the upper event, but the result was the same.

    1.When I move a character to the right direction, naturally I push the right-key.
    2.When I change the direction, for example, I push the down-key suddenly.
    3.The event is not called.

    To call the event, I must release completely the key button once, and then push another button.
    But I dislike such a way because it is not comfortable.
    Please tell me how to solve this problem.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SimonSchroeder
      wrote 27 days ago last edited by
      #2

      The most likely answer is: buy a better keyboard! You might be expecting key jamming or ghosting (https://en.wikipedia.org/wiki/Key_rollover). There are online checks for key rollover.

      1 Reply Last reply
      0
      • B Offline
        B Offline
        Bondrusiek
        wrote 21 days ago last edited by
        #3

        Hi,
        try use key handling in this way: https://stackoverflow.com/questions/23816380/using-multiple-keys-in-qt-c
        I implement this in my simple qt game. Can check: https://github.com/Przemekkkth/top-down-shooter-qt

        1 Reply Last reply
        1

        2/3

        29 Apr 2025, 06:57

        • Login

        • Login or register to search.
        2 out of 3
        • First post
          2/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved