Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# WPF button click

Tags:

c#

.net-3.5

wpf

I wounder if there is a way to check if a key is clicked?

What I want to achieve is creating something like text editor, I have finished most of the parts. Now when I press on a button, I have a function under element PreviewKeyUp and the other PreviewKeyDown ... Is there something like PreviewKeyClick or KeyClick?

PS: I'm using visual studio 2010 and compiling against .NET Framework 3.5 ... I know I can use 4.0 but 3.5 is due to restrictions on client PC. The application targets a specific client and I can't update the .NET Framework on the client machine. If more details is needed, don't hesitate to ask.

like image 230
sikas Avatar asked Mar 14 '26 02:03

sikas


1 Answers

In general, for text editors you would need to handle TextInput (or PreviewTextInput) and KeyDown/PreviewKeyDown events. The latter handles keys not included in TextInput events.

like image 60
CodeNaked Avatar answered Mar 16 '26 16:03

CodeNaked



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!