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.
Qt 6.11 is out! See what's new in the release blog

keyPressEvent isn't called simultaneously.

Scheduled Pinned Locked Moved Unsolved Game Development
3 Posts 3 Posters 1.0k Views 1 Watching
  • 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 on 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 on 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
      • BondrusiekB Offline
        BondrusiekB Offline
        Bondrusiek
        wrote on 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

        • Login

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