add more robust normalizeUIKeys

[fixes #914]
Merge remote-tracking branch 'origin/pr/959' into v1.6.3