The usual approach to measuring times is to use the timer input capture function. You record the time the event began and then the time the event ended and subtract the results to find the difference (accounting for timer overflows). Depending on the frequency of the signal you may have to use two input capture channels connected to the same signal. With two channels you can record differences down to one timer tick.
For the encoder the pulse accumulator can tell you how many pulses each output has produced but it may be more tricky to determine the direction of the encoder since the pulse accumulator does not directly record the time that a pulse occured. If you need to know the direction of the encoder rotation then you need know which edge is occuring first so it may be easier to use input captures for this again. Depending on the frequency of rotation you may not need to use the timer pins for this since a keyboard interrupt may be able to respond quickly enough.