def sim_key_by_time(x, y, period=1e-16, thresh=50):
    half_period = (period / 2)
    key_x = key_y = None
    if (x > 100):
        x = 100
    if (y > 100):
        y = 100
    if (x < (- 100)):
        x = (- 100)
    if (y < (- 100)):
        y = (- 100)
    if ((x < (- thresh)) or (x > thresh)):
        if (x > 0):
            key_x = r
        else:
            key_x = l
        x = (abs(x) - thresh)
    else:
        x = 0
    if ((y < (- thresh)) or (y > thresh)):
        if (y > 0):
            key_y = u
        else:
            key_y = d
        y = (abs(y) - thresh)
    else:
        y = 0
    tx = ((x / (100 - thresh)) * half_period)
    ty = ((y / (100 - thresh)) * half_period)
    release_period = (((2 * half_period) - tx) - ty)
    if key_x:
        key_unit(key_x, tx)
    if key_y:
        key_unit(key_y, ty)
def sim_key_by_time(x, y, period=1e-16, thresh=50):
    half_period = (period / 2)
    key_x = key_y = None
    if (x > 100):
        x = 100
    if (y > 100):
        y = 100
    if (x < (- 100)):
        x = (- 100)
    if (y < (- 100)):
        y = (- 100)
    if ((x < (- thresh)) or (x > thresh)):
        if (x > 0):
            key_x = r
        else:
            key_x = l
        x = (abs(x) - thresh)
    else:
        x = 0
    if ((y < (- thresh)) or (y > thresh)):
        if (y > 0):
            key_y = u
        else:
            key_y = d
        y = (abs(y) - thresh)
    else:
        y = 0
    tx = ((x / (100 - thresh)) * half_period)
    ty = ((y / (100 - thresh)) * half_period)
    release_period = (((2 * half_period) - tx) - ty)
    if key_x:
        key_unit(key_x, tx)
    if key_y:
        key_unit(key_y, ty)