How to capture a keystroke - including control chars?
Gary_WJul 26 2006 — edited Jul 31 2006Forms 10g, win2k
Before you get fired up to flame me that this has been asked before, this is not the garden variety "need to capture keystroke" question!
I need to capture keystrokes, including control characters, as they are typed. Ideally I would like to get an ASCII value when a single keystroke is typed. I want to avoid timers for the obvious performance reasons. I already tried a couple of javabeans with no success:
keyfilter.jar
This comes with the forms demo. Does NOT fire an event on a keypress. Returns a key_code, key_character and a key_modifier. Returns the same key_code for upper and lower letters (the uppercase value), but by examining the key_character and key_modifier (ctrl, alt, etc) I can determine the control character. If only it fired an event on a keypress. I tried to simulate it firing an event by making a 1 character field with the automatic skip set to yes and putting my code to examine the keystroke in the next field's WHEN-NEW-ITEM-INSTANCE trigger. However, entering a control character does not cause the automatic skip to work. Also, some control combinations are set in the fmrweb.res file and are interpreted by forms (ctrl-H brings up help) before I can catch it.
keytyped.jar
This is from the example provided by our friend Francois here:
http://forms.pjc.bean.over-blog.com/article-1827045.html.
It DOES fire an event on a keypress. Interestingly, it returns the same value for both upper and lowercase letters too, but it returns the lowercase value. I tried to enter control characters and the value for the lowercase letter is returned or a value of 191.
Does anyone have a modified version of the keyfilter bean that fires an event on a keypress? Or perhaps another bean I can try? Is there a mechanism to make this program use its own fmrweb.res file in order to turn off default forms control characters?
Thanks for your attention,
Gary