Hello,
I am trying to trap the left and right Square Brackets "[" "]" and the left and right Curly Braces "{" "}". On my keyboard, the curly braces are generated by the Shift+[ and Shift+]. So, two keys on the keyboard should provide the 4 values I need. When I press the keys in an editor, as you can see, the correct characters are printed. However, the values for "[" in lparam variable is 219 (it should be 91) and for "]", it comes through as 221 (it should be 93). So, I don't understand why the event handler gets the wrong values for the square brackets.
For the curly braces, I have to press the Shift key and all that comes through to the event handler is 16. I'm not sure how to handle a shifted keystroke to get effectively, a single character of "{" or "}". I've played around with this for a while and cannot see an obvious solution to these issues. The code segments are as below:
If anyone can help point me in the right direction, I'd really appreciate it.
Thank you.
Experiment with this:
if(id==CHARTEVENT_KEYDOWN) { if (TranslateKey((int)lparam)=='[') Print ("[ key pressed"); else if (TranslateKey((int)lparam)==']') Print ("] key pressed"); else if (TranslateKey((int)lparam)=='{') Print ("{ key pressed"); else if (TranslateKey((int)lparam)=='}') Print ("} key pressed"); }
Experiment with this:
Thank you very much for your suggestion! I really appreciate it :)
Experiment with this:
Just a heads up, your solution works like a charm! Thank you :D

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello,
I am trying to trap the left and right Square Brackets "[" "]" and the left and right Curly Braces "{" "}". On my keyboard, the curly braces are generated by the Shift+[ and Shift+]. So, two keys on the keyboard should provide the 4 values I need. When I press the keys in an editor, as you can see, the correct characters are printed. However, the values for "[" in lparam variable is 219 (it should be 91) and for "]", it comes through as 221 (it should be 93). So, I don't understand why the event handler gets the wrong values for the square brackets.
For the curly braces, I have to press the Shift key and all that comes through to the event handler is 16. I'm not sure how to handle a shifted keystroke to get effectively, a single character of "{" or "}". I've played around with this for a while and cannot see an obvious solution to these issues. The code segments are as below:
If anyone can help point me in the right direction, I'd really appreciate it.
Thank you.