You should describe what isn't working with your code, is it not properly detecting collision? Because then you should look at your collision detection function.
But in general, for 2d you should separate the checking of horizontal and vertical collision. If you do that then there won't be "diagonal collision", just a horizontal collision and a vertical collision.
So for a very basic pseudo example:
dx = 0;
dy = 0;
If left pressed and no horizontal collision at x - 2 then dx = -2;
If up pressed and no vertical collision at y - 2 then dy = -2;
doMove(dx, dy);
So if the player is pressing up and left, and there's only a horizontal collision, the player will still move up. This will allow snug fits into a corner with a more robust movement system. This isn't the best way to go with implementing movement, but it will serve your purposes with the way you've chosen.