fork download
  1. public boolean all_keys_on()
  2. {
  3. return numlock(true) && capslock(true) && scrolllock(true);
  4. }
  5.  
  6. public boolean all_keys_off()
  7. {
  8. return numlock(false) && capslock(false) && scrolllock(false);
  9. }
  10.  
  11. public boolean numlock(boolean b)
  12. {
  13. Toolkit tool = Toolkit.getDefaultToolkit();
  14. try
  15. {
  16. tool.setLockingKeyState(KeyEvent.VK_NUM_LOCK,b);
  17. }
  18. catch(Exception e)
  19. {
  20. return false;
  21. }
  22. return true;
  23. }
  24.  
  25. public boolean capslock(boolean b)
  26. {
  27. Toolkit tool = Toolkit.getDefaultToolkit();
  28. try
  29. {
  30. tool.setLockingKeyState(KeyEvent.VK_CAPS_LOCK,b);
  31. }
  32. catch(Exception e)
  33. {
  34. return false;
  35. }
  36. return true;
  37. }
  38.  
  39. public boolean scrolllock(boolean b)
  40. {
  41. Toolkit tool = Toolkit.getDefaultToolkit();
  42. try
  43. {
  44. tool.setLockingKeyState(KeyEvent.VK_SCROLL_LOCK,b);
  45. }
  46. catch(Exception e)
  47. {
  48. return false;
  49. }
  50. return true;
  51. }
Runtime error #stdin #stdout 0.27s 213120KB
stdin
Standard input is empty
stdout
Standard output is empty