Тёмный

How To Handle Keyboard Events In C# | KeyUp, KeyDown, KeyPress Method Simplified! 

Shaun Halverson
Подписаться 10 тыс.
Просмотров 30 тыс.
50% 1

Hi!
In today's video, we are going to talk about how to get user input from the keyboard. In Windows Forms apps, there are events called KeyPreview, KeyDown, KeyUp, and KeyPress events and they all work in their own unique ways. I have scowered the internet for answers for hours and there is no good video out there covering this subject, so I made one to solve that! Today we make a simple C# windows forms app and I explain the difference between each type of function and how they operate within Visual Studio!
Software Engineering / Programming for beginners / variables types / computer science /compsci / coding for beginners / learn how to program / learn how to code / C# variables / C# for beginners / coding tutorial / programming tutorial
Thanks for watching! :)
ASCII CHART I used
docs.microsoft...
Want to see more? Click on this spicy link :D
/ @shaunhalverson
Assets in the thumbnail were provided by artists on
www.canva.com
All art and copyright ownership belongs to the artists on Canva and is under the protection of the Canva pro membership.
BACKGROUND MUSIC INFO
------------------------------
Lofi Hiphop Mix 2021 | Lofi beats to study | No Copyright Lofi Hip Hop 2021
• Lofi Hiphop Mix 2022 |...
👇 More info below in the description & comments 👇
lofi geek on Spotify: spoti.fi/3dTH2FN
Lofi Study Playlist: www.youtube.co....
Lofi Playlist 2021: • LoFi Mix 2022 | LoFi H...
Listen more Lofi hip hop / Chill beats to relax, study, work, sleep
Follow lofi geek's channel:
www.youtube.co....
lofi hiphop beats to study/relax to from lofi geek, lofi playlist, lofi 2021.
I do not own this song. ANY/ALL credit for the music goes to Lofi Geek.
------------------------------
ENDING SONG INFO
------------------------------
chill. by sakura Hz / sakurahertz
Creative Commons - Attribution 3.0 Unported - CC BY 3.0
Free Download / Stream: bit.ly/chill-sa...
Music promoted by Audio Library • Chill - sakura Hz (No ...
------------------------------
🎵 Track Info:
Title: chill by sakura Hz
Genre and Mood: Hip Hop & Rap · Calm
---
🎧 Available on:
Spotify: open.spotify.c....
SoundCloud: / ro. .
RU-vid: • sakura Hz - chill. (Ne...
iTunes: itunes.apple.c....
Google Play: bit.ly/googlep...
---
😊 Contact the Artist:
/ sakurahertz
ru-vid.com....
open.spotify.c....
/ sakurahertz
/ sakurahertz
📷 Contact the Photographer:
/ benjamin_hung
www.benjamin-h...
/ benjaminhung
/ tokyotones
#programming #tutorial #learntocode

Опубликовано:

 

19 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 56   
@ARMAN-rv1er
@ARMAN-rv1er 2 года назад
I've been struggling for learning this for a long time! You're the only one that could help me understanding this confusing thing in c#! Thank you A LOTTT!
@Havii
@Havii 2 года назад
This is great for anyone starting. You should build onto this and make a mini project where u add features to add per video so at the end of the series or however you wanna call/do it, you and the viewers who follow along have something :D
@UncannyGirl
@UncannyGirl 2 года назад
Where's the ASCII chart link? There's literally everything but it.
@ShaunHalverson
@ShaunHalverson 2 года назад
Oops, thank you for that. I forgot to link it.
@ShaunHalverson
@ShaunHalverson 2 года назад
docs.microsoft.com/en-us/dotnet/api/system.windows.forms.keys?view=windowsdesktop-6.0 ^^That's the one I used to make this video
@1osagye
@1osagye 10 месяцев назад
I don’t know how to to tell you lol X. Hop
@hefonthefjords
@hefonthefjords 2 года назад
You are a legend. I spent three days trying to work this out on my own and from microsoft resources and only got confused. This explaination was perfect. Cheers!
@ShaunHalverson
@ShaunHalverson 2 года назад
Thank you!! I am glad you enjoyed it and also I had a terrible time looking around for information like this so I decided to make a video about it. Thanks for the sub!
@hefonthefjords
@hefonthefjords 2 года назад
Thanks for making useful tutorials! I'm studying software development at college just now so I will be working my way through the rest of your videos to get ahead of the pack. :)
@ShaunHalverson
@ShaunHalverson 2 года назад
@@hefonthefjords that’s awesome! Good luck :)
@根本花里子
@根本花里子 Год назад
You are literally a saint, thank you from the bottom of my heart!!🙏🧡🧡
@eamonburns9597
@eamonburns9597 Год назад
This is a great tutorial, just one note though, I tried to detect the Enter key with the KeyDown event and it worked
@NetheReaper
@NetheReaper 2 года назад
You're a lifesaver! Thank you!
@ShaunHalverson
@ShaunHalverson 2 года назад
Thank you for watching! :)
@theodevries784
@theodevries784 Год назад
Oh my god this made me realize I've been just been styling in xaml this whole time when I couldve been using properties, wtf
@boody8844
@boody8844 2 года назад
Thank you so much for this !!
@ShaunHalverson
@ShaunHalverson 2 года назад
Thank you for watching!
@c.allmebro
@c.allmebro 2 года назад
that was an amazing explanation thankyou so much
@upsilan_mitstrima
@upsilan_mitstrima Год назад
is there a way to check for a key even if the window is not in focus (for example i am on my browser and i want the window to change something whenever i press "p") even if the browser is the window that is in focus
@lask3785
@lask3785 2 года назад
Shaun you are still the goat
@ShaunHalverson
@ShaunHalverson 2 года назад
Hahaha thank you, I read your comments and enjoy them every time
@lask3785
@lask3785 2 года назад
@@ShaunHalverson Haha also you need a discord server, people could ask you questions and stuff maybe give you some ideas as well.
@ShaunHalverson
@ShaunHalverson 2 года назад
@@lask3785 good idea! I shall make one
@NoName-qf7lu
@NoName-qf7lu Год назад
Thank you!!
@vincentlacsaiii3026
@vincentlacsaiii3026 2 года назад
Great tutorial. Do you know how to disable some specific keyboard keys in wpf?
@maylo_g5636
@maylo_g5636 Год назад
Muchas gracias amigo, tu video me sirvió de mucho +1 Subs
@Lunar-rb9um
@Lunar-rb9um 2 года назад
What if you wanted to use more than 1 character? For Example: 'S A E' would trigger a button
@ShaunHalverson
@ShaunHalverson 2 года назад
You would map those keyValues to the buttonYouWantToClick.performclick() methods. So if you wanted to click the same button with S A or E, you would say "if these keyvalues happen, click these buttons"
@bernardopower5267
@bernardopower5267 Год назад
Hi , do u know how to code backspace hard input key in c# for a calculator?
@dereine7975
@dereine7975 2 года назад
Thanks!!!!
@user-kl5ss9en2t
@user-kl5ss9en2t Год назад
there is keydown event in maui??
@gabisaintro
@gabisaintro Год назад
How to make shortcut like, Ctrl+Numpd1
@theodevries784
@theodevries784 Год назад
Can someone figure out how to do this in WPF?
@szanownypanprofesor6016
@szanownypanprofesor6016 Год назад
in window constructor, after InitializeComponent, enable KeyDown to the window: this.KeyDown += OnKeyDown; and create OnKeyDown method to handle pressed keys.
@alisami3193
@alisami3193 Год назад
I want to press (Ctrl+q) by mouse , I tried but did n`t work
@MrJohnRBX
@MrJohnRBX 2 года назад
do you know how to use a keyboard key in background?
@ShaunHalverson
@ShaunHalverson 2 года назад
I’m not sure what you mean? Can you clarify a little?
@MrJohnRBX
@MrJohnRBX 2 года назад
@@ShaunHalverson For example, pressing a key without having to open the program, pressing it in the background, is that understood? 😜
@ShaunHalverson
@ShaunHalverson 2 года назад
@@MrJohnRBX Yeah understood lol, I am unsure how to do that without tabbing into the program somehow. Since these things seem to operate based off “focus” on the controls. If it doesn’t have focus at all in the program, I am unsure if you could get it to work. Did you attempt it after finishing what was done in the tutorial?
@MrJohnRBX
@MrJohnRBX 2 года назад
@@ShaunHalverson I did it but I want to try something different, I am making a text to speech application and I wanted to do it so that I could write in the application from the background :P
@ShaunHalverson
@ShaunHalverson 2 года назад
@@MrJohnRBX ooo that sounds cool, I’m sure there’s something you can do to potentially do that or something close to it
@veilie3649
@veilie3649 2 года назад
Does this work if my calculator is in a usercontrol?
@ShaunHalverson
@ShaunHalverson 2 года назад
It should!
@panickal
@panickal Год назад
I'm going insane with these fucking videos and forums I literally just want to detect a keypress what does the form have to do with ANYTHING AND WHY DOES IT NEED BUTTONS
@VolkanCavlak
@VolkanCavlak 2 года назад
I think you forgot key_press?
@colterares4878
@colterares4878 5 месяцев назад
HOW DID YOU KNOW ?!?
@daxqo3906
@daxqo3906 Год назад
bro put on a shirt
@soundrogue4472
@soundrogue4472 Год назад
Please just to the coding, who cares about the color
Далее
How to Send Clicks and Key Strokes to Any Application
33:48
C# Mouse and keyboard events (Arabic)
13:32
Просмотров 2,2 тыс.
Create a keylogger in C# Part 1
10:18
Просмотров 36 тыс.
ASMR Programming - Spinning Cube - No Talking
20:45
Просмотров 3,9 млн