getchar() and putchar() in adobe javascript
FrancisFukuyama Dec 17, 2010 11:03 PMOne of the simplest programs that are written in C for newbies is pure input and output of characters from pressed keys in succession (with some max repetition allowed by the operating system settings for key pressed for extended period).
#include <stdio.h>
main(){
int c;
while ( (c=getchar()) != EOF)
putchar(c);
}
I want to write a similar minimal program in acrobat javascript.
The script may be document/application level ... most preferably not attached to any specific field on any page and listens for the Keystroke ... ie a pressed key.
However, if it MUST be attached to a field ... then that field would be a button field which is on the current page and in focus ... but this will take away the simplicity I desire and as exhibited in the C program above which compiles and works.
I want to print the letter corresponding to the key pressed on the console using this statement or another ...
console.println(c);
[QUESTION] How do I read the key pressed ?
Thanks,
Francis Fukuyama
as a newbie i did lots of search in the sdk and guide before asking this question.
i need acrobat to do events globally irrespective of page based on what key is pressed in certain contexts so it should not interfere with other normal operations.
alternatively, i need three of four modifiers of mouse events but nothing is more convenient on the fingers than pressing a key like y/n for yes/no .
Are there any non-reserved keys or non-reserved clicks events that can be recorded at the global, application or document level, or else be intercepted by a button and then recorded in some kind of file or hidden field for that button and then automatically "recorded or downloaded" into a text file as a data ?
Thanks again for any help.
Francis
Aug 11, 2002
You would have to create a custom plug-in to have any hope of accomplishing this. JavaScript cannot do what you describe. You might want to pose this question in the Acrobat SDK forum here if you haven't already.




