"printable" key handlers trigger twice
Maybe easiest to reproduce by placing duplicate items during map generation, and trying to pick them up; whenever available, two items are picked up. The reason for this seems to be that tcod::input emits two events; one as a character, another as text:
Key { code: Char, printable: 'g', pressed: true, left_alt: false, left_ctrl: false, right_alt: false, right_ctrl: false, shift: false, alt: false, ctrl: false, text: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }
Key { code: Text, printable: 'g', pressed: true, left_alt: false, left_ctrl: false, right_alt: false, right_ctrl: false, shift: false, alt: false, ctrl: false, text: [103, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }
The solution seems to be simple: extend the match patterns to include code: Char.
This might also explain #54, possibly (Char event triggers, is handled by the menu handler, then the Text even triggers, which is then handled by the main input handler)
Huh, according to https://bitbucket.org/libtcod/libtcod/pull-requests/76/set-key-c-0-on-textinput-events/diff this is caused by a problem in libtcod that was fixed in 1.6.5. I guess upgrading tcod-rs from 1.6.3 might help fix this properly?