Alter the single modifier code to use device independent key masks as opposed to key codes

Fixes #1712