Psalms 18:21

For I have kept the ways of the LORD, and have not wickedly departed from my God.

The verse is David's testimony that he had kept the ways of the Lord and had not wickedly departed or turned away from his God. That keeping meant having all God's judgments continually before him, neither casting aside nor departing from His statutes. It meant also guarding himself against his own iniquity and sin. Its uprightness was a cleanness of hands kept from evil, a refusal to do wrong, in direct contrast to using the hands for iniquity and injustice, so that one who so keeps can speak of his uprightness before God. This obedience, uprightness, and cleanness of hands is given as the reason the Lord rewarded him according to his righteousness.