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

LINQ Contains Syntax with List<string>
Visual Studio 2010 SDK, Get Caret Column
Reading rich text from an Excel cell
How to map class to database table?
How to open a window then load my XAML file to it? (XAML and C#)
Unexpected empty sequence in linq to sql result
C#: Line information when parsing XML with XmlDocument
Need help with a regular expression
Adding enum to combobox
Make font italic and bold
check a url is from a specific site
What are the new featurs of .Net4 that can improve the development in windows application,vsto
C# tool for printing into PDF which is compatible with Graphics class [duplicate]
Best way to separate two base64 strings
WinForm Controls in context menu
WPF: windowsformshost with webbrowser is very slow

Categories

HOME
virtual-machine
jenkins-pipeline
formatting
display
samsung-gear-s2
cracking
phpexcel
spring-data-solr
theory
openbsd
kairosdb
http-status-codes
multibinding
k-means
internet-explorer-7
ringcentral
civicrm
django-rest-auth
bootstrap-datetimepicker
turn.js
vala
onclicklistener
grunt-contrib-uglify
smart-device
emr
spock
folder
concrete5
tunnel
stochastic-process
mediastream
server-side-swift
file-descriptor
colorbox
superclass
intervention
synchronized
togglebutton
line-endings
richtext
bipartite
optional-parameters
tinybox2
database-administration
pebble-js
nd4j
factorization
dcast
skbio
sqldataadapter
ruby-1.8.7
serial-communication
lytro
first-order-logic
firewire
data-representation
gmaps4jsf
google-experiments
xmla
kss
grunt-contrib-connect
pnunit
sat4j
time-frequency
farpoint-spread
data-layers
nativequery
mahara
adabas
maven-javadoc-plugin
mobile-robots
aspnet-compiler
listpicker
mandelbrot
pyxplot
stringstream
cocotron
pudb
microsoft-speech-platform
nsregularexpression
expresso-store
systrace
datasheet
project-files
opendir
functional-specifications
cpack
nscharacterset
silverlight-2.0
mdd
rpxnow
stackless
memory-consumption

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile