Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. qkeyevent Ignore modifiers

qkeyevent Ignore modifiers

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 3 Posters 1.9k 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.
  • MegamouseM Offline
    MegamouseM Offline
    Megamouse
    wrote on last edited by Megamouse
    #1

    How can i ignore modifiers and only show the actual key that was pressed?

    E.g. I don't want to get the key for ( when I press shift+8 on a german layout. I want the key for 8.

    edit: It would also be okay if I could simply disable the modifiers completely

    jsulmJ 1 Reply Last reply
    0
    • MegamouseM Megamouse

      How can i ignore modifiers and only show the actual key that was pressed?

      E.g. I don't want to get the key for ( when I press shift+8 on a german layout. I want the key for 8.

      edit: It would also be okay if I could simply disable the modifiers completely

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Megamouse Why don't you simply check http://doc.qt.io/qt-5/qkeyevent.html#modifiers? See http://doc.qt.io/qt-5/qt.html#KeyboardModifier-enum

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      MegamouseM 1 Reply Last reply
      2
      • jsulmJ jsulm

        @Megamouse Why don't you simply check http://doc.qt.io/qt-5/qkeyevent.html#modifiers? See http://doc.qt.io/qt-5/qt.html#KeyboardModifier-enum

        MegamouseM Offline
        MegamouseM Offline
        Megamouse
        wrote on last edited by
        #3

        @jsulm I'm sorry but this isn't helpful at all

        JonBJ 1 Reply Last reply
        0
        • MegamouseM Megamouse

          @jsulm I'm sorry but this isn't helpful at all

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

          @Megamouse
          If you want to just know which key is pressed, look at http://doc.qt.io/qt-5/qkeyevent.html#key member function. Unlike http://doc.qt.io/qt-5/qkeyevent.html#text, the former gives the raw key, without applying modifiers to generate the corresponding Unicode character.

          MegamouseM 1 Reply Last reply
          2
          • JonBJ JonB

            @Megamouse
            If you want to just know which key is pressed, look at http://doc.qt.io/qt-5/qkeyevent.html#key member function. Unlike http://doc.qt.io/qt-5/qkeyevent.html#text, the former gives the raw key, without applying modifiers to generate the corresponding Unicode character.

            MegamouseM Offline
            MegamouseM Offline
            Megamouse
            wrote on last edited by
            #5

            @JonB key() returns different codes for let's say... 1 and shift+1 (namely ! on german keyboards).
            but I need the same value regardless of the shift

            JonBJ 1 Reply Last reply
            0
            • MegamouseM Megamouse

              @JonB key() returns different codes for let's say... 1 and shift+1 (namely ! on german keyboards).
              but I need the same value regardless of the shift

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by
              #6

              @Megamouse
              From the docs, I would have expected http://doc.qt.io/qt-5/qkeyevent.html#key to return Qt::Key_1 (http://doc.qt.io/qt-5/qt.html#Key-enum) in both cases. What do they each return?

              MegamouseM 1 Reply Last reply
              0
              • JonBJ JonB

                @Megamouse
                From the docs, I would have expected http://doc.qt.io/qt-5/qkeyevent.html#key to return Qt::Key_1 (http://doc.qt.io/qt-5/qt.html#Key-enum) in both cases. What do they each return?

                MegamouseM Offline
                MegamouseM Offline
                Megamouse
                wrote on last edited by
                #7

                @JonB Key_1 and Key_Exclam

                JonBJ 2 Replies Last reply
                1
                • MegamouseM Megamouse

                  @JonB Key_1 and Key_Exclam

                  JonBJ Offline
                  JonBJ Offline
                  JonB
                  wrote on last edited by
                  #8

                  @Megamouse That's a bit of a blow, then! :(

                  1 Reply Last reply
                  0
                  • MegamouseM Megamouse

                    @JonB Key_1 and Key_Exclam

                    JonBJ Offline
                    JonBJ Offline
                    JonB
                    wrote on last edited by JonB
                    #9

                    @Megamouse
                    Then I think you'll have to go down to the level of http://doc.qt.io/qt-5/qkeyevent.html#nativeScanCode

                    Don't ask me where you look up its return values though, as I don't know that!

                    And if that doesn't work, and you/I don't see another method to get at raw keyboard keys, I can only see that you'll have to write a large switch...case statement on QKeyEvent::key() for your keyboard!

                    1 Reply Last reply
                    0

                    • Login

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