psuedo-code
if( Input.GetKey(KeyCode.D))
{
//walk right
}
else if(Input.GetKey(KeyCode.A))
{
//walk left
}
else
{
//return to idle
}
your script is close but you need to check these three conditions together. ALSO, you need to make sure the character is not airborne. if they are, the character will simply be falling and not in a walking OR idle animation
lastly this doesn't really have that much to do with toolkit 2d, this is general unity/c# programming