Fix caret position calculation
Use key in dict pattern instead of dict.has_key

In Python 3, dict.has_key doesn't exist.
Merge branch 'master' of github.com:mooz/percol