Home

Awesome

#PsychScript

A HTML5/Javascript library for online behavioural experiments.


PsychScript is intended to make the process of creating and running psychology experiments online much less bewildering. It consists of the following:


The idea is to allow users' to write one line of PsychScript to make the experiment do what they want it to, rather than a dozen of JavaScript.

For example, collecting a keyboard response, which previously would have looked something this:

var accepted_keys = new Array('a', 'b', 'c');
var response
document.onkeydown = function(event) {
    var key = String.fromCharCode(event.keyCode)
	if (accepted_keys.indexOf(key) != -1) {
		response = key
	}
	else if (accepted_keys.indexOf(key.toLowerCase()) != -1) {
		// In case acccepted_keys were given in lowercase.
		response = key
	};
};

PsychScript allows us to achieve the same with:

var response = get_keyboard_response('abc');

A definite improvement!

Similarly,

var divs_to_hide = ['probe_text', 'probe_image', 'feedback_text']
for(var i=0; i<divs_to_hide.length; i++){
    document.getElementById(divs_to_hide[i]).style.display = "none";
};

becomes

hide(['probe_text', 'probe_image', 'feedback_text'])

You should get the idea by now.


###Demos To see some of PsychScript in action, check out these demos:


###Contribute This is a project for everyone, and all contributions are welcome.

The immediate problems to be solved include: