Fix Tk keyboard modifier masks on Windows

Should fix #2302 and #2673.