Search Unity

Control + Tab?

Discussion in 'Scripting' started by SparrowsNest, Jan 11, 2019.

  1. SparrowsNest

    SparrowsNest

    Joined:
    Apr 6, 2017
    Posts:
    1,648
    In my game i have a HUD that shows an indicator to something, and additionally it can display some details, you hit tab to toggle the display of the indicators by some rule-set, up until now I've used the shift key(+tab) to tell if the player wants to switch the detail on/off, but now the main use of the shift key is to speed up the camera movement speed so it needs to find a new home, I tried to use control( because I have a feeling alt + tab won't work very well) but it just doesn't seems to work.

    If I'm pressing tab it switches the normal mode perfectly fine, if I'm pressing control it doesn't respond at all.

    Literally all I changed was the KeyCode from Tab to LeftControl, is this some windows shortcut / unity editor shortcut?
    doesn't seems to do anything.

    *search doesn't show anything besides for stuff like xl
     
  2. Stardog

    Stardog

    Joined:
    Jun 28, 2010
    Posts:
    1,243
    I don't think Ctrl works properly in the editor. It should work in a build.
     
  3. jvo3dc

    jvo3dc

    Joined:
    Oct 11, 2013
    Posts:
    1,350
    It seems to me the KeyCode should still be Tab. The modifier just changed from Shift to Control. In OnGUI, just get that information from the current Event.
    Code (csharp):
    1.  
    2. Event event = Event.current;
    3. if (event.isKey && (event.type == EventType.KeyDown))
    4. {
    5.     if ((event.keyCode == KeyCode.Tab) && event.control)
    6.     {
    7.         // Tab went down while Control was held
    8.     }
    9. }
    10.  
    https://docs.unity3d.com/ScriptReference/Event.html
     
  4. SparrowsNest

    SparrowsNest

    Joined:
    Apr 6, 2017
    Posts:
    1,648
    I'm sorry, I meant to say i changed shift to control, tab is still in use.
    I assumed so, thanks.