Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
Python, Lua, Tcl, C and C++ training - public course schedule [here]
Private courses on your site - see [here]
Please ask about maintenance training for Perl, PHP, Java, Ruby, MySQL and Linux / Tomcat systems
gets of multi-key stroke (Alt-F5)

Posted by bbondi (bbondi), 23 May 2005
I'm new at this cool language and have a request for help concerning keyboard input. We have an app that runs from the DOS shell and users may press multi-key strokes as a command to make the screen form change.

Then enter data in the screen form to be saved.

Is there a site with a tutorial that will cover this topic? Is there a mentor that can address this issues on tis site?


Posted by admin (Graham Ellis), 23 May 2005
Hi, Welcome.

"gets" isn't ideal for you because it reads up to a new line character and only then returns a "cooked" string - for example if you entered 7, backspace, 5, return it would just pass back 5, return.   But there are other ways.

Are you using Tk?   If so, the event handler will do what you want.

Brief answer ... I'm on the road; if you follo wup, I'll be back at my desk and able to write more fully on Wednesday.  I do have some examples back there I think  

Posted by bbondi (bbondi), 23 May 2005
Yes, I installed the Win version of both TCL/Tk and Expect. I'm working thru some of the examples and may glean some info, but, yes further discuss and examples are needed if I'm to truly 'grok' this issue and how it may apply to the DOS app mentioned.

I hope the road is smooth.

Posted by admin (Graham Ellis), 25 May 2005
OK. In Tk, you can pick up individual keystrokes by binding events, and that's probably what you're looking for.  If you start off with a little Keysym tester you should be able to see all your keystrokes and the data associated with them.

This should give you all the information you need (and probably much much MORE than you need) and you can then filter out the unwanted events - have a look through the "other examples on same subject" we have on that page.

I suspect that you're looking for something like
bind .fred <Alt-KeyPress-F5> {.fred configure -text pressed}

Posted by bbondi (bbondi), 26 May 2005
OK, I have gotten way further along with that hint:
bind . <Control-Key-F12> { tk_messageBox -message "You pressed Control+F12 BINGO!" } ;

bind . <Alt-Key-F1> { tk_messageBox -message "You pressed Alt+F1 Way to go, you got a BINGO!" } ;
Is an example of what I've got so far which captures the Control/Alt kets in combo with the Funtion keys.

I'm thinking of capturing the keys for replay into the DOS KB buffer which is what I need to do to test the DOS console app I am working on.

So, now I'm wondering if there is a method to just create a file manually with the keys I need to send to the console app? Is there a method to send the keystrokes directly to the keyboard buffer?

Or, perhaps just using the redirect operator would do it?
tclsh DOSConsoleApp<keysToSend

Discussion, tips...


Posted by admin (Graham Ellis), 26 May 2005
You've only got ONE keyboard on your computer but potentially LOTS of applications, so the operating system buffers are bound to get in the way - after all, under most circumstances you only want them to forward events relevant to an application to that application.

This area is typically an operating-system dependent minefield and personally I've dealt with it under a very old DOS version, and under Solaris and Linux.  Can't know everything, and how keybaord buffers work under Windows is indeed one of my dunnos.

This page is a thread posted to the opentalk forum at and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2017: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: • WEB: • SKYPE: wellho