LaurentGomila/SFML — pull request #568 by Senzaki (2014-04-11 17:08:09+00:00)
Title: Support for scan codes

Since I needed it in my project, I worked on the support of scan codes into SFML. As mentionned in [this thread](http://en.sfml-dev.org/forums/index.php?topic=13692.msg95809#msg95809), scan codes enable the user to get a key according to its location, without having to take care of the different keyboard layouts (AZERTY, QWERTY...). sf::Event::KeyEvent now has a "scancode" field, which is an enum of many keys (see Keyboard.hpp for a full list). The reference keyboard is the qwerty keyboard. For instance, when the "A" key is pressed on an AZERTY keyboard, an event containing sf::Keyboard::A in the "code" field and sf::Keyboard::ScanQ in the "scancode" field is fired. The way system scancodes are translated to sfml scancodes is exactly adapted from the SDL source code (even the list of scancodes was taken from SDL). Mac OS is not supported yet, since I don't own any Mac computer (so the scancode field is not filled yet on this platform). The num keys are also properly recognized on Linux when using AZERTY keyboards (in the scancode AND code fields).
The pull request does not aim to be directly integrated in SFML : I didn't really know where to put the ScanCode enum, and I did not comment its values, etc... Its purpose is to be a workaround for the ones in need of scancodes support before the official implementation. And I would be glad if it could help the SFML devs during the creation of the official implementation as well.