c#


How do I make my application to know when the spacebar key is pressed globally on a low-level?


I want to call on a method to execute whenever the space key is pressed whether my application is on focus or running in the background. How do I this in C# ? Let s say the method to call on is sendData(). How do I hook my keyboard on a level level to execute the sendData() method whenever the space key is pressed using C#.
You need to listen for a key press, in your case you're looking for ConsoleKey.Spacebar, the documentation for it here: ConsoleKey Enum
Here is a quick and dirty sample:
Console.WriteLine("Press Spacebar to send data");
while (!(Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.Spacebar))
{
// iterate something (or nothing)
}
sendData(); // call your method afterwards
It's important to note that Console.ReadKey is blocking. My code sample is just to illustrate some basics.

Related Links

How to connect sql server express database to VS 2017
Importing XML with XML-Deserializer and Serializing with DataContract-Serializer
Offline Nuget Packages
How to convert store procedure to linq in nopCommerce c#
Sending data to EventHub from Asp.Net site
validate drop down menu in bootstrap form wizard
C# equivalent of Java's Generic Method that extends Comparable [closed]
Html.Password doesn't work as expected Razor
WebApi Authentication via Xamarin/UWP/Unity3D
How to create DataRelation between two tables in many-to-many relationship?
Xamarin Forms MSAL cache not storing tokens on iOS
Can a static member variable be used to cache a value in a static class?
How to get FirendlyName of OIDs associated with X509Certificate2?
Serilog in Asp.Net Core to SysLog sink
Draw a border around an oval picturebox
How to work around intentional waits which are causing false hot paths when profiling?

Categories

HOME
qlikview
actionscript-3
ssms
kendo-ui
stanford-nlp
wifi
formatting
windows-server-2008
phantomjs
comments
browserstack
scapy
yacc
segmentation-fault
theory
kairosdb
dynamics-crm-2011
adroitlogic
chef-recipe
opengrok
repeater
hql
pylint
samba
powerpivot
vivado-hls
audio-streaming
draw2d
aws-devicefarm
glibc
spring-webflow
android-wifi
dev-c++
klipfolio
concatenation
ecmascript-2017
expressionengine
request-uri
folder
overflow
boost-log
oracle-nosql
favorites
android-geofence
multi-user
azure-storage-files
form-fields
lfe
ssdp
mixed-models
flume-ng
taiga
synchronized
google-cloud-shell
bioperl
openpgp.js
boost-regex
petapoco
suitesparse
google-scholar
addressbook
stripes
indoor-positioning-system
strtol
ldd
android-xmlpullparser
hotkeys
avi
pebble-js
paypal-subscriptions
videoview
transport
jain-sip
glog
xmla
qxorm
register-allocation
oxygenxml
switchpreference
banana-pi
webshim
traceur
image-preloader
class-library
node-mongodb-native
google-voice
friendly-id
source-depot
pyxplot
panelgrid
generator-expression
qt5.1
screensharing
webpage-screenshot
django-1.4
mass-emails
azure-appfabric
subdirectories
web-search
expander
high-load
asp.net-1.1

Resources

Encrypt Message