Fix some bugs with the key mask.

Signed-off-by: Tyler O'Meara <Tyler@TylerOMeara.com>
Merge pull request #168 from Acidity/fixKeyMaskAgain

Fix some bugs with the key mask.