How do i duplicate previous key frame to another frame using python so far i have done this 

import bpy
scn = bpy.context.scene
obj = bpy.context.active_object

animData = obj.animation_data
action = animData.action
fcurves = action.fcurves
current_frame = scn.frame_current

#bpy.ops.action.copy()
k1 = bpy.context.scene.frame_current
bpy.ops.screen.keyframe_jump()
k2 = bpy.context.scene.frame_current
bpy.ops.screen.keyframe_jump(next = False)


k3 = bpy.context.scene.frame_current

k4 = bpy.context.scene.frame_set(k2-1)
k5 = bpy.context.scene.frame_current




for fcurve in action.fcurves :
    for p in fcurve.keyframe_points :


        if p.co.x == k3:
            p.co.x =k5


but this only move previous key frame to the k5 value .. i want to have duplicate of previous key frame
I've found it practical to keyframe_insert it:

keyframe_insert(frame=k5,data_path=fcurve.data_path)