glad to be an inspiration some how
and thanks for the update!
in another thread @sotiri suggested this code component in the Begin Routine tab.
core.Keyboard.prototype._addKeyListeners = function() {
this._previousKeydownKey = undefined;
const self = this;
window.addEventListener("keydown", (event) => {
if (event.repeat) {
return;
}
const timestamp = util.MonotonicClock.getReferenceTime();
if (this._status !== PsychoJS.Status.STARTED) {
return;
}
self._previousKeydownKey = event.key;
let code = event.code;
if (typeof code === 'undefined') {
code = core.EventManager.keycode2w3c(event.keyCode);
}
let pigletKey = core.EventManager.w3c2pyglet(code);
self._bufferIndex = (self._bufferIndex + 1) % self._bufferSize;
self._bufferLength = Math.min(self._bufferLength + 1, self._bufferSize);
self._circularBuffer[self._bufferIndex] = {
code,
key: event.key,
pigletKey,
status: core.Keyboard.KeyStatus.KEY_DOWN,
timestamp
};
self._unmatchedKeydownMap.set(event.code, self._bufferIndex);
self._psychoJS.logger.trace('keydown: ', event.key);
event.stopPropagation();
});
}
based on what you said- do you think it will help? i cannot test it until Pavlovia will be back
If @sotiri says so, probably yes; he has quite some skillz
1 Like
he was right! it works
thank you @thomas_pronk and @sotiri i am marking it as solution for others until the bug is fixed.
1 Like
ajus
April 6, 2021, 9:40am
24
Hi! I am experiencing the same issue and the code above does nothing to improve it. @chayabenyehuda Did it help you out in the end?
Best
aisa2
April 7, 2021, 8:48pm
25
Same here-- no luck pasting the above code in the begin routine tab (though it doesnât crash the experiment either). Should any of this be changed for our individual experiment? Anything different on mac vs pc?
Text box is still not editable online; though strangely I can highlight the default text. Also, I get this error very briefly after quitting via the escape key, before the regular quit message:
TypeError: this._last_renderer.view is null
_getDOMRelativeWorldTransform
However, this only happens if I have tried to type something.
sotiri
April 8, 2021, 9:50am
26
Hi @ajus , @aisa2 , which PsychoJS version are your projects based on currently? I believe 2021.1.3 no longer has this the problem, x
aisa2
April 8, 2021, 3:01pm
27
Hi @sotiri , I was in 2021.1.2 when I made that post. I just upgraded to 2021.1.3; now the error message doesnât appear, but I am still unable to type text. I have removed and re-added the textbox component to make sure nothing is carrying over, but to no avail.
sotiri
April 8, 2021, 3:08pm
28
OK could you send me a link to the project? Thanks, x
aisa2
April 8, 2021, 3:19pm
29
Done, thanks for looking into this!
ajus
April 9, 2021, 11:55am
30
Hi! I am on 2021.1.3 as well. The textbox is editable, but I have to press every key for a while until the letter appears. Thanks for helping!
sotiri
April 9, 2021, 12:01pm
31
Hi @ajus , thanks for flagging, the fix is in master now and should be included with the 2021.1.4 release in prep as we speak, x
aisa2
April 9, 2021, 5:33pm
32
Hi all,
Based on troubleshooting with @sotiri , the temporary solution is to put this code snippet in the âBefore Experimentâ section of one of your code components on the JS side (NOT begin routine as stated above). But none of this will be needed once 2021.1.4 is released.
core.Keyboard.prototype._addKeyListeners = function()
{
this._previousKeydownKey = undefined;
const self = this;
window.addEventListener("keydown", (event) =>
{
if (event.repeat)
{
return;
}
const timestamp = util.MonotonicClock.getReferenceTime();
if (this._status !== PsychoJS.Status.STARTED)
{
return;
}
self._previousKeydownKey = event.key;
let code = event.code;
if (typeof code === 'undefined')
{
code = core.EventManager.keycode2w3c(event.keyCode);
}
let pigletKey = core.EventManager.w3c2pyglet(code);
self._bufferIndex = (self._bufferIndex + 1) % self._bufferSize;
self._bufferLength = Math.min(self._bufferLength + 1, self._bufferSize);
self._circularBuffer[self._bufferIndex] = {
code,
key: event.key,
pigletKey,
status: core.Keyboard.KeyStatus.KEY_DOWN,
timestamp
};
self._unmatchedKeydownMap.set(event.code, self._bufferIndex);
self._psychoJS.logger.trace('keydown: ', event.key);
event.stopPropagation();
// event.preventDefault();
}
);
window.addEventListener("keyup", (event) =>
{
const timestamp = util.MonotonicClock.getReferenceTime();
if (this._status !== PsychoJS.Status.STARTED)
{
return;
}
self._previousKeydownKey = undefined;
let code = event.code;
if (typeof code === 'undefined')
{
code = core.EventManager.keycode2w3c(event.keyCode);
}
let pigletKey = core.EventManager.w3c2pyglet(code);
self._bufferIndex = (self._bufferIndex + 1) % self._bufferSize;
self._bufferLength = Math.min(self._bufferLength + 1, self._bufferSize);
self._circularBuffer[self._bufferIndex] = {
code,
key: event.key,
pigletKey,
status: core.Keyboard.KeyStatus.KEY_UP,
timestamp
};
const correspondingKeydownIndex = self._unmatchedKeydownMap.get(event.code);
if (typeof correspondingKeydownIndex !== 'undefined')
{
self._circularBuffer[self._bufferIndex].keydownIndex = correspondingKeydownIndex;
self._unmatchedKeydownMap.delete(event.code);
}
self._psychoJS.logger.trace('keyup: ', event.key);
event.stopPropagation();
}
);
};
1 Like