C#: How do you send OK or Cancel return messages of dialogs when not using buttons?

How would you return the OK message in the condition of a textbox that will proceed when the user presses Enter, and will send Cancel when the user presses Ctrl+Q?

Disregard: solution- this.dialogresult = dialogresult.ok or dialogresult.cancel.

c#
Edit
Report