The examples posted above do not do exactly the same thing, but if conciseness translated well to efficiency, then
PHP Code:
temp.v = {keydown(3)-keydown(1),keydown(2)-keydown(0)}
gives the proper velocity vector, or
PHP Code:
temp.v = vectornormalize({keydown(3)-keydown(1),keydown(2)-keydown(0),0}).subarray(0,2)
for consistent velocity in all directions.