Adding keyboard shortcut to a blender script

I know it's probably not the most elegant, or even a usable, solution, but is it possible to use a keyboard shortcut, say pageUP in a python blender script?

OR find out the code behind the shortcut, like one can do elsewhere in blender, like a button's code for example.

I have been looking in the input user preferences and hovered over the shorcut , which gives me:

keyMapItem.map_type
bpy.data.window_managers["WinMan"] ... map_type


But i'm not sure how to use this, in a script, to give me the shortcut "page up" functionality.

• What is "blender script"? Is it the Text editor or Python console or is this about adding a shortcut with python script? What function you want to make a shortcut for? Jan 20 '17 at 14:20
• I don't think you want to use the shortcut, you want to use the tool that the shortcut activates. Jan 20 '17 at 14:27
• I have a series of one frame movie strips, which I want to iterate through and extend each strip from one frame to 10 frames. I use the pageUP and pageDpwn shortcut to manually iterate through them, then select them and change the length from one to ten. I was looking to automate this process with a python script within Blender. Jan 20 '17 at 14:40
• I cannot find the syntax that relates to the shortcut. I know to hover over a button, or whatever, to get the python code, but am stuck for shortcuts. Jan 20 '17 at 14:42
• @reggie Go to the user preferences > INPUT and search for "Page Up" with the mask set to Key Binding Jan 20 '17 at 16:21

It would be better(and probably easier) to do this directly rather than using trying to use the keyboard shortcuts in the code. Try this:

seqs = bpy.context.scene.sequence_editor.sequences_all
for seq in seqs:
seq.frame_final_duration = 10


Or if you want to just modify selected strips:

seqs = bpy.context.scene.sequence_editor.sequences_all
for seq in seqs:
if seq.select:
seq.frame_final_duration = 10


Or if you want to just modify the strips based in their length:

seqs = bpy.context.scene.sequence_editor.sequences_all
for seq in seqs:
if seq.frame_final_duration == 1:
seq.frame_final_duration = 10

• I was trying to use the shortcut to jump through my clips in the scene, so I could select the clips that are only one frame long. I have other longer clips in there too, sorry didn't make myself clear. Jan 21 '17 at 8:47
• Your answer is spot on for my comment (3rd comment down)! Jan 21 '17 at 8:50
• Could your code be modified to only select the clips that are 1 frame long and ignore the others? Jan 21 '17 at 8:54