?Setting the "Clock" for midi

How do I do that?

I am tryiing to use MIDI and am running into some “learning curve” problems.
I record audio using a Presonus Diximax into a Layla 24. I set the clock to read from the Diximax. Now I have a USB keyboard and I want to record along with the audio from the Diximax. I can get them to “almost” sync by using the WAV clock on Ntrack’s MIDI preferrence.
Is there a better way to sync?
Thanks,
Bax