Use keyboard to adjust stimulus position

Description of the problem:
Hi there, I have encountered a simple question but cannot find out what’s wrong.
I want to use the keyboard to adjust both position(using “w” “s” “a” “d”) and orientation(using"left" “right”) of the stimulus (a bar).
The orientation of the bar could follow my keyboard input precisely, but the position couldn’t. For instance, If I press the key “a”, the bar won’t move. While if I press the key “left” next, the bar’s orientation will change, of course, it’s position will change as well (because the key “a” has been pressed before).
It seems that the position of the bar is not updating every frame, while the orientation is updating?

Here is my JS code, I inserted this piece into the “stimulus presenting each frame” routine.

var thisResp
if (bar.status === PsychoJS.Status.STARTED){
    thisResp = psychoJS.eventManager.getKeys();
    // adjust orientation
    if ("left" == thisResp[0]) {
        bar.ori += 4;
    }
    if ("right" == thisResp[0]) {
        bar.ori -= 4;
    }
    // adjust position
    if ("a" == thisResp[0]) {
        bar.pos[0] -= 1;
    }
    if ("d" == thisResp[0]) {
        bar.pos[0] += 1;
    }
    if ("w" == thisResp[0]) {
        bar.pos[1] += 1;
    }
    if ("s" == thisResp[0]) {
        bar.pos[1] -= 1;
    }
  }

Thank you very much!!

@jon sorry for interrupting but could I get some help? It has bothered me for about two days:(

I finally solved this problem by adding this code:
bar.setPos(bar.pos[0],bar.pos[1])
But I still find it very wired… what’s the difference between the orientation(can self-update) and the position(need setPos manually)?
I am very grateful for any comment, thank you very much!

Dear @MINGHAO_LUO many thanks for flagging. You’ll be pleased to know in the latest version of PsychoJS now available on Pavlovia your code should work without having to call setPos().

Please check out the js/override.js script below for example,

https://run.pavlovia.org/thewhodidthis/e2e_change_attributes/index_override.html

Please post back if the issue persists or if you come across any other problems getting this to work.

that will be very helpful, Many thanks!