Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Find out which key would be generated if the shift modifier was pressed?

Find out which key would be generated if the shift modifier was pressed?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 2 Posters 649 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.
  • P Offline
    P Offline
    pokemonsrqt
    wrote on last edited by
    #1

    In a Keys.onPressed event handler:

    Keys.onPressed: {
        console.log(event.key) // 61
    }
    

    can I find out what the event.key code would have been if the shift key was pressed?

    J.HilkJ 1 Reply Last reply
    0
    • P pokemonsrqt

      In a Keys.onPressed event handler:

      Keys.onPressed: {
          console.log(event.key) // 61
      }
      

      can I find out what the event.key code would have been if the shift key was pressed?

      J.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      @pokemonsrqt hi, that would be Qt.ShiftModifier

      Keys.onPressed: {
              if ((event.key == Qt.Key_Enter) && (event.modifiers & Qt.ShiftModifier))
                  console.log("Shift & Enter pressed");
          }
      

      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      1 Reply Last reply
      0
      • P Offline
        P Offline
        pokemonsrqt
        wrote on last edited by
        #3

        When the shift key is not pressed, I want to know what the event.key code would have been if the shift key had been pressed.

        If you think my question is strange, I would like to add context by saying that it relates to the problem in this question: https://forum.qt.io/topic/97622/how-can-i-let-users-use-control-for-zoom-in-and-control-for-zoom-out, where the shift key does not affect the event.key code if the control key is simultaneously pressed. As a possible to solution to that problem, I would like to be able to compute what the event.key code would have been had the shift key been pressed.

        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