Bear in mind this does not fix the Alt Gr keypresses. Pressing this key will still produce the same symbols/behaviors when the keylogger is not enabled.
What this fix does: we are receiving the character value for a KeyPress and we are handling it by ignoring it if any modifier keys are set. In this case "Ctrl + Alt" which I will be trying to accomplish in a later fix (if I can figure out how to do this).
For example, a user with a german keyboard layout presses (Ctrl + alt + 2), which is the same as AltGr + 2, the call to our PressedKeys list will do the following
-check if key modifiers are set
-check if the list contains a key with a character value that is comparable to a key
If the key is a normal character, for example user presses (Ctrl + Alt + k) on a german keyboard layout, the result would be true and the method would return, ignoring appending the character 'k' to the log
If the key is not a normal character that is comparable to the value of a Key, our call will fall through to the next call, and add the character that is returned. For example, user presses (Ctrl + Alt + 2) to produce the special character, the Keys enum values won't contain a key with that symbol and our list won't either so it will fall through and print the special character
Instead of wasting lots of time creating a string from a char array,
creating a string from another char array, concatenating them both into
a new string, and casting the keychar to a string to see if the string
contains it, make the operation natural and very efficient by creating a
new char array that has both invalid characters and making sure the
illegal character array does not contain the element.
-Fixed spaces showing up in weird orders.
-Fixed issue where pressing some modifier keys would append the KeyPress
events text prior to the Appended highlighted text from the KeyDown
event. Example: User presses Windows Key + R. it would log "r[Win +
[R]"
Fixed the message loop, called Application.Run in the thread and not the
object, using ApplicationContext object we can identify which thread to
tell the message loop to return