I’m very late (6 years to your comment and 11 to the OP) But anyway, your first series of shortcuts only works for the keyframes literally visible in the timeline window. If you have more than about 50 layers, or a small enough window, this isn’t the best solution.
The best GUI approach I’ve found to delete keyframes of all layers would be:
1. Select All.
2. Reveal them (t for opacity for example).
3. Click the stopwatch button.
4. Repeat 2-3 for each property.
The best scripting approach seems to be to create a loop cycling through the layers, a sub loop(s) cycling through the properties and using app.executeCommand(21) on each, as Xavier says. Best to create an undo group for this. I don’t see any reason why this is “dangerous”. It’s just the delete command. It saves a lot of time to delete all keyframes at once rather than deleting them last to first. And the undo group adds safety.
To marginally speed things up, disable rendering for the script with:
app.suppressRender = true;
//code
app.suppressRender = false;