How do I detect if for example the "4" key is pressed on the keyboard together with shift?

Some browsers report the key 4 regardless of shift is held or not, others report they key typed. Meaning it depends on keyboard layout (US layout has Shift+4 turn into $, nordic layout has Shift+4 turn into ยค, German layout has... well I don't know, I don't want to type out special cases for all language keyboard layouts in the world.

Is there any solution for this "key typed is reported" problem?