We are about to switch to a new forum software. Until then we have removed the registration on this forum.
hi,
i m trying to build a simple text editor. should i use switch-case for every button in the keyboard or is there a short way or else? i dont know so much about coding but i m trying to get used to. any help appreciated, thank you.
rios
Answers
You can avoid a lot of cases by using checking ranges of ASCII: http://www.bibase.com/images/ascii.gif
thanks so much. i got the case thing. and how can i make this "key" variable visible on screen, and not on top of each other but on a grid?
My advise is always prefer keyCode for keyboard detection:
https://processing.org/reference/keyCode.html
Only when we need both upper & lower cases we need key instead:
https://processing.org/reference/key.html
P.S.: Disregard that silly CODED test. It's purely old superstition. :O)
Minimal implementation of key presses appearing and delete. I have not tested delete much, I just saw that it was key == 8 here: http://forum.processing.org/one/topic/backspace-deleting-text-from-strings.html
Plenty to do before this is a usable text editor. Chances are textWidth will become your new best friend: https://processing.org/reference/textWidth_.html
thank you for answers, i ll try both suggestions. i ll probably ask for some more help in the future
http://studio.ProcessingTogether.com/sp/pad/export/ro.9Zo$UbIWYZEDR/latest