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

Fixes #1712 

Basically, using key codes meant the right keys didn't work. Instead I've used the device independent masks - exactly what they're for.

Aside: I don't like how the masks are hard-coded as the tags for the popup menu in the prefs, but that's how it's always been so there's no regression here.