Tag archive for: event handling

How to detect keyboard presses made to the browser screen with JavaScript

When you are building a browser-based game, being able to track key presses is helpful.

For this purpose, you can register a JavaScript function that gets called when the browser detects a key is being pressed.

After the browser detects a key press, it will send information about the key to your function.

When your function is able to get the key that is pressed, it can then use this information to update the game state.

In this post, let’s look at how we can detect keyboard presses made to the browser screen with JavaScript.

How to raise and consume custom events in C#

When something happens asynchronously, the events mechanisms in C# is a good way for different components of our C# programs to notify one another about it.

For example, when the report generation component had the finance report ready, it can raise an event to components that had registered interest in that finance report.

This post documents how we can raise and consume custom events in C#.