---
title: "Catch KeyUp Event on WinForm C#"  
description: "Catch KeyUp Event on WinForm C#"  
author: "Anonymous User"  
published: 2013-09-04  
updated: 2013-09-04  
canonical: https://www.mindstick.com/forum/1444/catch-keyup-event-on-winform-c-sharp  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# Catch KeyUp Event on WinForm C#

I attempt to [catch](https://www.mindstick.com/forum/159341/how-to-use-try-and-catch-in-java-for-exception-handling-and-what-happens-when-an-exception-occurs) F5 on System.Windows.Forms for that I wrote:

[partial class](https://www.mindstick.com/forum/155717/define-partial-class-in-mvc) MainForm

{

(...)

this.KeyUp += new System.Windows.Forms.KeyEventHandler(this.MainForm_KeyUp);

(...)

}

public partial class MainForm : [Form](https://www.mindstick.com/forum/6/multi-form-mfc-application)

{

(...)

[private](https://www.mindstick.com/blog/11097/java-access-modifiers-the-public-and-the-private-modifiers) void MainForm_KeyUp(object sender, KeyEventArgs e)

{

[Log](https://www.mindstick.com/articles/126269/the-main-uses-of-log-cabins)("MainForm_KeyUp");

if (e.KeyCode == Keys.F5)

{

RefreshStuff();

}

}

}

But my [event](https://www.mindstick.com/articles/167719/marquee-hire-benefits-of-event-lighting-hire-london) [catching](https://www.mindstick.com/forum/1582/catching-messagebox-result) looks not working.

Do you know how to cactch EventKey on System.Windows.Forms ?

## Replies

### Reply by Sumit Kesarwani

Hi Jeet,\

The keypreview property of the form must be set to true

When this property is set to true, the form will receive all KeyPress, KeyDown, and KeyUp events. After the form's event handlers have completed processing the keystroke, the keystroke is then assigned to the control with focus.


---

Original Source: https://www.mindstick.com/forum/1444/catch-keyup-event-on-winform-c-sharp

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
