Rpg problem

i have got the basic of an rpg, i have the background moving as apose to the character so i had to make the background moving the other way. now i want to make sure my character cant go throught the walls, with the code i have put in place the character can go throught the walls if you press two keys like up and right at the same time could somebody please help me