LOUISVILLE, Ky. — The whole key to college basketball is for a team to play its best at just the right time. No one appreciates that more than Kansas, which got hot in mid-winter and has remained that way. That includes Thursday night, when the Jayhawks went on a run at a key moment in the second half and made their way into the Elite Eight.

Perry Ellis, a senior whose career is reaching its apex at just the time he wanted it to, scored 27 points and ignited a 9-0 surge from which Maryland never recovered. Kansas, the NCAA Tournament’s No. 1 overall seed, went on to a 79-63 win, extending a long successful run. Its last loss was two months ago today.

Kansas (33-4) will mark that anniversary by preparing to face Villanova on Saturday here at the KFC Yum! Center for the right to reach the Final Four.

“I just want to keep competing, just having fun with it,” said Ellis, who is playing in his fourth Big Dance for the Jayhawks. That is something no one ever had done before a small point guard in the 1980s did it, a young fellow named Mark Turgeon, who Thursday night was coaching the other team.

advertisement | advertise on newsday

“He’s playing with a lot of confidence. I didn’t think he forced things tonight,” Turgeon said of Ellis. “We knew he was driving right, and we still couldn’t guard it. He can shoot the three, he can do mid-range, he can get all the way to the glass and post up. And he’s a great kid. I’ve followed his career and I know there have been some ups and downs, but it’s great that he’s finishing the way he’s finishing.”

Ellis was instrumental in finishing off Maryland (27-9) despite its stellar backcourt of Rasheed Sulaimon (18 points) and Melo Trimble (17). The Terrapins led much of the first half and trailed the Jayhawks by only two at intermission. Then Kansas turned up its defense and played a lot better on offense.

The score was 43-43 before Ellis made a jump shot, then a layup 32 seconds later. It was off to the races for a Kansas team that marked its visit here by having dinner Tuesday at Churchill Downs.

“I think he’s unguardable,” said Ellis’ teammate, Wayne Selden Jr. “He can score from all three different levels. He has great touch with the ball.”

Selden has been just about as good in his own memorable March. He scored 19 Thursday night, including the five points that completed the pivotal 9-0 run. He believes that it helps to play alongside someone who is such a handful. “It’s easy because coming off screens with him, they play to the pick-and-pop,’’ Selden said. “If they guard me too heavy, I go to him, and if not, I just keep driving.”

Turgeon, who always has and always will have Kansas inscribed on his heart, grew up in Topeka and realized his great dream by playing for the Jayhawks. (He joked that his recruiting to the school consisted of this: “I was down on my knees begging Coach [Larry] Brown to take me.”)

The losing coach was asked if the hurt was more acute because it came against his alma mater. “No,” Turgeon said. “We lost to the best team in the country, 33-4 now, the No. 1 seed in the tournament. They’re playing really well. They’ve just crushed people lately. And in the end, it looks like they crushed us. I don’t know if it was that bad . . . but they’re good.”