Support key mappings of more than 2 keys

Fixes #1271.
Please update the comment here too