Send text with Esc key

Batch, ASP, JScript, Kixtart, etc.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 13 years and 2 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
Regis
Posts: 2
Last visit: Sun Jul 24, 2011 6:34 pm

Send text with Esc key

Post by Regis »

Hi, The script below is working properly. But i am looking for a way, that the text in the text-field is written to Text.txtwhen the escape key (Esc) is pressed, instead of clicking the Send button. Any help will be highly appreciated._____________________________________________<Script Language="VBScript">Dim fso, oFileSet fso = CreateObject("Scripting.FileSystemObject")Set objShell = CreateObject("WScript.Shell")Sub WriteSet oFile = fso.OpenTextFile("Text.txt",8,true)sTxtArea = document.all("TxtArea").ValueoFIle.Write sTxtAreaMsgBox "The text has been added to Text.txt", 64oFile.closeEnd Sub</SCRIPT><TextArea style="Height:200;Width:400;font-Size:12;color:Black;background-color:bisque;font-weight:Normal;font-family:Microsoft Sans Serif"Name=TxtArea TabOrder=2 Wrap=off></TextArea><!--I would like to change the following line, so that the text is written to Text.txt when the Esc key is pressed--><input type="Button" value="Send" onclick="Write">_____________________________________________Regis
User avatar
Regis
Posts: 2
Last visit: Sun Jul 24, 2011 6:34 pm

Send text with Esc key

Post by Regis »

Hi, The script below is working properly. But i am looking for a way, that the text in the text-field is written to Text.txtwhen the escape key (Esc) is pressed, instead of clicking the Send button. Any help will be highly appreciated._____________________________________________<Script Language="VBScript">Dim fso, oFileSet fso = CreateObject("Scripting.FileSystemObject")Set objShell = CreateObject("WScript.Shell")Sub WriteSet oFile = fso.OpenTextFile("Text.txt",8,true)sTxtArea = document.all("TxtArea").ValueoFIle.Write sTxtAreaMsgBox "The text has been added to Text.txt", 64oFile.closeEnd Sub</SCRIPT><TextArea style="Height:200;Width:400;font-Size:12;color:Black;background-color:bisque;font-weight:Normal;font-family:Microsoft Sans Serif"Name=TxtArea TabOrder=2 Wrap=off></TextArea><!--I would like to change the following line, so that the text is written to Text.txt when the Esc key is pressed--><input type="Button" value="Send" onclick="Write">_____________________________________________Regis
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Send text with Esc key

Post by jvierra »

The code works every time you press the escape key. The 'body' element has to hav an id so the keystrokes are caught by the code and filtered.

There is NO html that can do what you ask. It MUST be done in script.

The native language of an HTA is VBScript but you can convert it to JavaScript if you know hoew to use JavaScript event capture.

To filter for a single keystroke the event has to be on the body element.

If the code is not working you copied it wrong. Just place the code inside of a file with an HTA extension and execute the file.

This topic is 13 years and 2 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked