Trapping Function keys in NCurses

I have written Display program using C and NCurses Library. I want to
search particular data and display depending upon
the input taken from user. Function key F1 indicates start of Input and
F2 indicates end of input. I want to Trap F1 and F2.
How do I trap. Can anyone help me.

Right now I have to press Escape key and then Function key F1. Take
input and again Escape has to be pressed and then F2.