LEFT RIGHT SHIFT OnGUI

does someone know how to get left and right shift keyCodes by using events in OnGUI function… i dont have any problems doing it in Update function…

// this code works… but does not detect the shift keys

if(kbdGUIEvent.isKey)     // kbdGUIEvent is Event.currect type
{
     pressCount = 0;
     canAssignButton = false;
     nputKBD.SetButton(InputKBD.buttonsList[activeButtonIndex], kbdGUIEvent.keyCode);
}

// this code detects shift keys in update with Input instead of Events but doen’t work in OnGUI with Events

if(kbdGUIEvent.keyCode == KeyCode.LeftShift) // does not return true whe i press shift keys
{
     Debug.Log("left shift"); // does not return anything
     pressCount = 0;
     canAssignButton = false;
     InputKBD.SetButton(InputKBD.buttonsList[activeButtonIndex], KeyCode.LeftShift);
}
if(kbdGUIEvent.keyCode == KeyCode.RightShift) // does not return true whe i press shift keys
{
     Debug.Log("right shift");// does not return anything
     pressCount = 0;
     canAssignButton = false;
     InputKBD.SetButton(InputKBD.buttonsList[activeButtonIndex], KeyCode.RightShift);
}

can you put that in [code ] [/code ] tags? far easier to read…

Try:

  if (Input.GetKeyDown(KeyCode.LeftShift)) {
     Debug.Log("Left Shift");
  }
 
  if (Input.GetKeyDown(KeyCode.RightShift)) {
     Debug.Log("Right Shift");
  }

This is the problem it works in update function by using the Input class but i need to detect the keys in OnGUI function using the Event class … I’m doing custom input system that way i want to do it in OnGUI : )))

As Nicholas once said - Input manager currently ‘sucks’ :slight_smile:

Unfortunately, you cannot get an event on key press and its key code (inside the Update method) using the Input class - as you would do inside OnGUI using the Event class. :slight_smile:

Yep i have seen this video : )…
In general my opinion is that the engine is great for non serious games and i like it very much but it needs some important functionality improvements which are going to make it really nice to work with !!! :sunglasses:

From my standpoint (having years of experience with client-side business app platforms) Unity is very stable, predictable and nice to work with. :wink: