okay, so if you've got a hspeed and vspeed like this:
xsp = (right - left) * spd;
ysp = (down - up) * spd;
then to correct for the diagonal speed boost, all you have to do is this:
if (xsp != 0) and (ysp != 0) { xsp *= sqrt(0.5); ysp *= sqrt(0.5); }
If you were using the built-in variables hspeed, and vspeed (which you should unless you have a good reason for not doing so), then all you would have to do is this:
if (speed > spd) { speed = spd; }
if you have some random direction and speed, you can make sure the speed is exactly equal to spd, while maintaining the same direction, like this:
var _m = spd / sqrt(xsp * xsp + ysp * ysp); //(will get divide by zero error if xsp and ysp are both zero)
xsp *= _m;
ysp *= _m;
but again, if you were using the built in movement variables, all you would have to do is:
speed = spd;