Keyfast
Script
Free

Select Rotation Keyframes

By Jack Vaughan
Updated 11/1/2025

About

Selects only rotation keyframes on selected layers. Useful for quickly isolating rotation animation when editing keyframes.

Code

// Cavalry Script: Keyfast - Select rotation keyframes
// Mirrors the behavior of the position selector for rotation.
(function selectRotationKeyframes() {
var ROT_ATTRS = ["rotation", "rotation.x", "rotation.y", "rotation.z", "shapeRotation"]; // guard for 2D/3D/shape
var isRotationAttr = function(attrPath) {
if (!attrPath || typeof attrPath !== "string") return false;
var a = ("" + attrPath).toLowerCase();
if (a === "rotation") return true;
if (a.indexOf("rotation.") === 0) return true;
if (a.indexOf(".rotation") !== -1) return true;
if (a.indexOf("shaperotation") !== -1) return true;
return false;
};
var uniq = function(arr) { var m = {}; var out = []; for (var i=0;i<arr.length;i++){ var v=arr[i]; if(!m[v]){ m[v]=true; out.push(v);} } return out; };
var listRotationAttributes = function(layerId) {
var attrs = [];
try { var animated = (typeof api.getAnimatedAttributes === "function") ? (api.getAnimatedAttributes(layerId) || []) : []; for (var i=0;i<animated.length;i++) if (isRotationAttr(animated[i])) attrs.push(animated[i]); } catch (_) {}
for (var j=0;j<ROT_ATTRS.length;j++) if (attrs.indexOf(ROT_ATTRS[j]) === -1) attrs.push(ROT_ATTRS[j]);
return attrs;
};
var getRotationKeyIdsForLayer = function(layerId) {
var ids = [];
var rotAttrs = listRotationAttributes(layerId);
for (var i=0;i<rotAttrs.length;i++) {
var attr = rotAttrs[i];
try {
var kIds = (typeof api.getKeyframeIdsForAttribute === "function") ? (api.getKeyframeIdsForAttribute(layerId, attr) || []) : [];
for (var k=0;k<kIds.length;k++) ids.push(kIds[k]);
} catch (_) {}
}
return ids;
};