The Levenshtein distance, the standard metric for determining how different words are from each other, can easily be modified to change the penalty for different letter replacements. For example, you can say that the penalty for substituting an 'a' for 's' is 1, and 'a' for 'p' is 10 (or whatever).
Google does this already and I would assume they aren't the only ones.
I once accidentally typed "cinnabd oatterb" into Google, yet it knew I wanted "Command Pattern". Still works today.