How would I use the arrow keys to move rectangle?

Qt Code:
  1. Rectangle {
  2. id:point
  3. anchors.centerIn: parent
  4. width: 20
  5. height: 20
  6.  
  7. opacity: 0.2
  8.  
  9. MouseArea {
  10. anchors.fill: parent
  11. drag.target: root
  12. onPositionChanged: {
  13. if(drag.active) {
  14. dragged()
  15. }
  16. }
  17. }
  18. Keys.onPressed: {
  19. if (event.key == Qt.Key_Left) {
  20. console.log("move left");
  21. event.accepted = true;
  22. point.x-=1;
  23. }
  24. }
  25. }
To copy to clipboard, switch view to plain text mode