How to perform a different action if two keys are held down at the same time vs either being pressed separately

I am trying to make a gameobject do the following:

Do Action1 when A is pressed.

Do Action2 when B is pressed

Do Action3 when A & B are pressed

I am writing in C#.

I found this answer, but I can’t make it work and it’s in JS. Maybe there is a more concise solution?

Thanks!

private bool action3Performed ;

 void Update()
 {
     if( ( Input.GetKey( KeyCode.A ) && Input.GetKeyUp( KeyCode.B ) ) || ( Input.GetKeyUp( KeyCode.A ) && Input.GetKey( KeyCode.B ) ) )
     {
         Debug.Log( "Do action 3");
		 action3Performed = true ;
     }
     else if( Input.GetKeyUp( KeyCode.A ) )
     {
		 if( action3Performed )
		 {
			action3Performed = false ; 
		 }
		 else
		 {
			 Debug.Log("Do action 1" ) ;
		 }
     }
     else if( Input.GetKeyUp( KeyCode.B ) ) 
     {
		 if( action3Performed )
		 {
			action3Performed = false ; 
		 }
		 else
		 {
			 Debug.Log("Do action 2" ) ;
		 }
     }     
 }