I think your select prev/next key stuff will be more a source of trouble than time saving, especially if the properties are folded, but well...
You will need 2 scripts like the one above, one for each shortcut (Shift+J / Shift+K) and even 2 more if you stick to your original idea with (Ctrl+Shift+J/K).
Give them names so that they always are in the same position in your script collection and bind those scripts.
For the code, it is very similar to the example above. For instance to select the next key:
$.global.script_doSelectNextKeys || (script_doSelectNextKeys = function script_doSelectNextKeys(){ var comp = app.project.activeItem, props, n, p, idx; if (comp instanceof CompItem){ props = comp.selectedProperties; for (n=0; n<props.length; n++){ p = props[n]; // if the property has no key, or no selected key, skip if (!p.numKeys || p.selectedKeys.length<1) continue; // idx: the index of the last selected keys (safe, that array is always sorted) idx = p.selectedKeys[p.selectedKeys.length-1]; // if the index of not the index of the last key, proceed if (idx < p.numKeys){ // deselect the property to deselect all of its keys p.selected = false; // reselect the next key p.setSelectedAtKey(idx+1, true); } // in any other situation, deselect all keys else if (p.selectedKeys.length>5){ // faster way to deselect plenty of keys p.selected = false; p.setSelectedAtKey(1, true); p.setSelectedAtKey(1, false); } else{ // default way to deselect keys while (p.selectedKeys.length) p.setSelectedAtKey(p.selectedKeys[0], false); }; }; }; return; }); script_doSelectNextKeys();
To select the previous key, replace
idx = p.selectedKeys[p.selectedKeys.length-1];
// if the index of not the index of the last key, proceed
if (idx < p.numKeys){
// deselect the property to deselect all of its keys
p.selected = false;
// reselect the next key
p.setSelectedAtKey(idx+1, true);
}
by
idx = p.selectedKeys[0];
if (1<idx){
p.selected = false;
p.setSelectedAtKey(idx-1, true);
}
The rest is exactly the same, give another name to the function (script_doSelectNextKeys ---> script_doSelectPrevKeys) , to the script, etc.
Xavier.