Advertisement
caitlinorbanek

FUCKING DONEZO

Dec 12th, 2011
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. char key_pressed;
  2.  
  3. PFont f;
  4.  
  5. // Variable to store text currently being typed
  6. String typing = "";
  7.  
  8. // Variable to store saved text when return is hit
  9. String saved = "";
  10.  
  11. void setup() {
  12. size(500, 500);
  13. f = createFont("Arial",16,true);
  14.  
  15.  
  16.  
  17. }
  18.  
  19. void draw() {
  20. background(255);
  21. int indent = 25;
  22.  
  23. // Set the font and fill for text
  24. textFont(f);
  25. fill(0);
  26.  
  27. // Display everything
  28. text("Click in this applet and type. \nHit return to save what you typed. ", indent, 40);
  29. text(typing,indent,90);
  30. text(saved,indent,130);
  31.  
  32.  
  33.  
  34. }
  35.  
  36.  
  37.  
  38. void keyPressed() {
  39.  
  40. if ((key >= 65 && key < 90) | (key >= 97 && key < 122)){
  41. key_pressed = (char)(key + 1);
  42. }
  43. else if (key == 91 | key == 122) {
  44. key_pressed = (char)65;
  45. }
  46.  
  47. // If the return key is pressed, save the String and clear it
  48. if (key == '\n' ) {
  49. saved = typing;
  50. // String is cleared by setting it equal to ""
  51. typing = "";
  52. } else {
  53. //Otherwise, concatenate the String
  54. // Each character typed by the user is added to the end of the String variable.
  55. typing = typing + key_pressed;
  56. }
  57. }
  58.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement