keyboardStdin.pp 574 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. program keyboardStdin;
  2. {$mode objfpc}
  3. uses
  4. ctypes, nds9;
  5. procedure OnKeyPressed(key: cint);
  6. begin
  7. if (key > 0) then
  8. iprintf('%c', key);
  9. end;
  10. var
  11. kbd: pKeyboard;
  12. myName: array [0..255] of char;
  13. begin
  14. consoleDemoInit();
  15. kbd := keyboardDemoInit();
  16. kbd^.OnKeyPressed := @OnKeyPressed;
  17. while true do
  18. begin
  19. iprintf('What is your name?'#10);
  20. scanf('%s', myName);
  21. iprintf(#10'Hello %s', myName);
  22. scanKeys();
  23. while (keysDown() = 0)do
  24. scanKeys();
  25. swiWaitForVBlank();
  26. consoleClear();
  27. end;
  28. end.