What if SFML allows to identify the keyboard model and provides enums for the most common used standardized scan codes? This allows to hardcode key mappings in source code, depending on the active layout of the user.
So, when a key event in SFML is triggered, it carries the scan code + a readable label (character itself or name of special key). The developer can then go and compare it with the active model's scan mode mapping table, like this:
if( event.type == sf::Event::KeyPressed ) {
if( event.key.scanCode == sf::Keyboard::toScanCode( sf::Keyboard::Q ) ) {
std::cout << "Key " << event.key.label << " was pressed." << std::endl;
// ...
}
}
getScanCode translates into a scan code that's valid for the active keyboard layout. Maybe there could even be a
sf::KeyboardLayout that holds the key code<->scan code mappings shown above.
sf::Keyboard::Q is still a key code, a way to specify the location of the key I want to listen for. This just has to be defined in SFML and can't be implemented to work localized for everybody (i.e. when I, as a German, give sf::Keyboard::Z, then the QWERTY Z key will be targeted, not the QWERTZ Z key).