Keyboard interfacing question
Devin Frioud
Posts: 17
Hello,
I was wondering about keyboard input for the propeller;
does the keyboard object return strings or individual characters?
Thanks,
Devin
I was wondering about keyboard input for the propeller;
does the keyboard object return strings or individual characters?
Thanks,
Devin
Comments
The original demo displayed the hex code for the keys pressed.
My modified version (below) outputs both the character and the hex code.
If you typed "Hello", the above code would display the following on the TV.
If you only wanted the characters you'd change the repeated section to this:
I wrote this demo a couple of hours ago.
I'll try the code!
Do you know of any objects that return keyboard input as strings?
Thanks,
Devin
Any such object would return a pointer to the string or place the input in a predetermined buffer like Mike's code does. You don't really need an object to do this since now you have Mike's method.
Just add:
To your constant and variable section and use Mike's method to get a string from the keyboard. You can, of course, have "MAXSTR_LENGTH" be any size you want (within reason).
It looks like Mike's code checks for zero length prior to backspacing. It looks like he uses "linelen" as the limit to the size of sting. I used "MAXSTR_LENGTH" for this limit since PST uses this. It would have been better if I had used Mike's 'linelen" instead (assuming I'm reading Mike's code correctly).