How can I monitor keyboard input while playing animation

Hello. I have an experiment to run, in which subjects make key response while watching an animation. It seems that I can't do anything else until the animation ends, i.e. I can't make Matlab (with PTB) do two things (playing animation & collecting response) at the same time. Could anyone here suggest a way for me to achieve this? Do I need special equipments or just delicate scripting will work?