Swapping player's controls in game (2D)

I have an object, which when triggered by the player has to swap the selected player’s left and right controls. The controls:

using UnityEngine;
using System.Collections;
using character;
using UnityStandardAssets.CrossPlatformInput;

public class confuse_powerup : MonoBehaviour {

    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.gameObject.name == "player1")
        {
            // SWAP LEFT,RIGHT CONTROLS
        } 
        else if (other.gameObject.name == "player2")
        {
            // SWAP LEFT,RIGHT CONTROLS
        }
    }
}

I tried swapping the keys but it didnt work :

var left = Input.GetKey("a");
var right = Input.GetKey("d");
left = Input.GetKey("d");
right = Input.GetKey("a");

I think you’re approaching this the wrong way… you don’t need to remap the key input to reverse the direction when you pick up that powerup - you simply modify the way that the input is applied to the character controller.

We can’t see your code for that bit, but you probably have something like:

transform.position += new Vector3(horizontalInput, verticalInput, 0);

So what you need to do is modify the horizontal input depending on whether the player is confused or not, like:

horiozontalInput *= isConfused ? -1 : 1;
transform.position += new Vector3(horizontalInput, verticalInput, 0);

And you use your OnTriggerEnter to set the isConfused bool.