If you are getting an "F" pressed instead of an "f" when you intended an "f" (or vice-versa), that means that the desktop computer thought the Shift key was still depressed. This can happen because the desktop never received the command to release the Shift key. If you are using UDP, note that it is not as reliable as as other network protocols, which is why it can be faster. The downside is the commands might get lost in transmission. You can always send another command to release the Shift key, it won't break anything.
"Escaping" characters won't work, as you've found out.
I've tried "releasing" shift key even 4 times and it's sometimes showing an "f" so this is not even working properly. I will try using TCP to se if it works better.
As @Roycefer said try TCP, as UDP packets can arrive in any order and can be completely dropped, whereas TCP packets will arrive in the order sent, and if one is lost will be resent.