<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def keyfilter(predicate, d, factory=dict):
 """ Filter items in dictionary by key {2: 3, 4: 5} See Also: valfilter itemfilter keymap """

    rv = factory()
    for k, v in iteritems(d):
        if predicate(k):
            rv[k] = v
    return rv