keep it in one's pants

verb
RareNot in standard dictionaries
1

To refrain from trying to have sex with someone.

2

To keep or stop oneself from further lusting over something (usually something not inherently sexual or lewd, like a fictional character), especially at a time and place that would be inappropriate for it.

#informal