-
Self-typing keyboard
I’ve probably massively over-complicated this, but every so often I need an onscreen keyboard in my videos and in the past I’ve just assembled the visuals. As a day project, I decided to build a comp with essential graphics which I could drop in whenever I need it and use checkboxes to control the keypresses.
During assembling this, I had the idea that maybe a cool feature would be to point it at a text layer and have it autotype the sentences. I’ve got most of it by adapting an expression Dan Ebberts helped me with previously, but I’m wondering if this is the most efficient way to go about it?
And I tried adapting this for a second text layer, so the text would appear to type on corresponding to the key presses, but it appears the text does not have a persistance, each frame resets it. I know I could use the typewriter preset, i just thought it would be cute to link them.
This is the expression I need to add to each keypress checkbox – it currently works only for the first letter, I’m trying to figure out why the next one doesn’t.
state=0;
thisKey = "h";
textArray = effect("Text layer")("Layer").text.sourceText.toLowerCase().split("");
keyDuration = effect("Key Down duration (frames)")("Slider")*thisComp.frameDuration;
p = effect("Set keyframe for start")("Checkbox");
if(p.numKeys > 0){
n = p.nearestKey(time).index;
if(p.key(n).time > time) {
n--;
}
if(n > 0){
t = p.key(n).time;
if(time < t+keyDuration && textArray[Math.floor((time-t)/keyDuration)] == thisKey){
state = 1;
} else {
state = 0;
}
}
}
state;
I’m doing this for fun and will post the final project here too, in case anyone else wants it.