When a user presses Shift+4 on my keyboard, he expects to get the '$' character in his favourite editor. The SDL event manager, on the other hand, will return not the ascii value of '$' but rather the ascii value of '4', and the modstate will have KMOD_LSHIFT or'd into it.

Is there a function in SDL or FreePascal or Delphi which takes an ascii value and a boolean (Shift on or off) and returns the ascii value of the shift character? How would I go about writing this function? I hope I don't have to manually construct a large lookup-table which worked something like this:

if ascii-value = byte('5') and SHIFT then result := '%' else result = '5'
if ascii-value = byte('6') and SHIFT then result := '^' else result = '6'
if ascii-value = byte('7') and SHIFT then result := '&' else result = '7'
etc etc

What a pain in the arse! And how do I know that all keyboards have '&' above the '7' key, '^' above the '6' key, and '%' above the '5' key? There must be some easier way of doing this!