Making an input field

I need a TMP objects that acts as input area (click, type something, click not in the area, not typing). I can’t understand how 2 do even selection & input. Guides that i found r about unity 2d, or doing it in editor but i need to create it in code

I already done this with 2d ui objects