How do I repaint/refresh/focus without calling Key Events multiple times?

My question is very specific.

My Goal:

I am creating an editor window that changes the scene view to create an orthographic, topdown, map navigation system. I have a grid of 12 x 8 GUILayout buttons in my editor window that refer to specific camera locations in the scene. Essentially easy topdown screen-based navigation for building levels. Think Zelda Classic(ZQuest).

The button that is green indicates where you currently are in the scene. This works perfectly, clicking on each grid box/button moves the scene cam to the proper location and updates my custom editor window so that the proper button is colored green.

		if(grid000 == true)
			GUI.color = Color.green;
		else
			GUI.color = Color.white;
		
		if(GUILayout.Button("", GUILayout.Width(width), GUILayout.Height(height)))
		{
				sceneCamX = 0 * -12; sceneCamZ = 0 * 11; SceneView.RepaintAll();
		}
		

		if(grid001 == true)
			GUI.color = Color.green;
		else
			GUI.color = Color.white;
		
		if(GUILayout.Button("", GUILayout.Width(width), GUILayout.Height(height)))
		{
				sceneCamX = 1 * -12; sceneCamZ = 0 * 11; SceneView.RepaintAll();
		}

My Problem:

I am also using WASD keys to move the camera around as well because this is quite convenient. Which also works perfectly except that the editor window is not updated properly to reflect where you are currently on the map(green button doesn’t update to the correct one). I am using the Event.current.character to get key presses.

Also, if I use Repaint() or Focus(), it causes problems. Whenever I press WASD it moves more than one screen over, usually all the way to the maximum map bounds I have set.

		if(Event.current.character == 'a' & sceneCamX < 0)
		{
			sceneCamX += 6;
			SceneView.RepaintAll();
		}	
		
		if(Event.current.character == 'd' & sceneCamX > -11 * 12)
		{
			sceneCamX -= 6;
			SceneView.RepaintAll();
		}
		
		if(Event.current.character == 'w' & sceneCamZ > 0)
		{
			sceneCamZ -= 5.5f;
			SceneView.RepaintAll();
		}
		
		if(Event.current.character == 's' & sceneCamZ < 7 * 11)
		{
			sceneCamZ += 5.5f;
			SceneView.RepaintAll();
		}

My Question:

Is there a way to refresh/repaint/focus that does not call the Event multiple times? Or perhaps a different way in an editor window to GetKeyDown so that it is only called a maximum of one time?

If you need more information to answer, please let me know, I didn’t want to post the entire 2,400 line script in here, unless it was necessary.

Thanks for your help!

Howey

If I understand the question correctly, then you should try this:

Event currentEvent = Event.current;

if(curentEvent.type == EventType.KeyDown)
{
    if (currentEvent.character == 'a' && sceneCamX < 0)
    {
        sceneCamX += 6;
        SceneView.RepaintAll();
    }

    if...
}