If you intend the concepts for 'hotkey' and 'hotstring' of autoit,
SciTE has already those mechanisms as abbreviation (as well as autocompletion and calltip).
"""So each time user presses enter, this function will check for the keywords like "If, For". If found any, then it will add two lines to scite and in the 2nd line it will paste the appropriate end keyword."""
If you use SciTEforAutoit, see au3abbrev.properties which has a collection of abbreviations.
and Try Ctrl+b instead of Enter.
If otherwise I got you wrong, you may invent your own wheel. good luck!