Many developers argue that analysis of user inputs is not an easy task and some of existing software’s inherently safer just because of bad inputs. I have a need to make an on-screen keyboard with standard features for my hydrological library (this library basically is a bunch of functions for spatial and temporal computation which has been developed in Vrije University of Brussels). The current article looks at a small part of my work starting from zero in programming to make a virtual keyboard. The advantage of this keyboard in an international environment like Brussels is that you may avoid wrong characters. In addition, these simple features make life much easier.
Sometimes, you prefer to use virtual keyboard instead of relying on the physical keyboard. You may use On-Screen Keyboard as an optional way to input data or you can mix entered data from physical and virtual keyboards. This On-Screen Keyboard is designed to display all the standard keys, virtually. Current version of On-Screen keyboard accepts input from 3 kinds of control including Combobox, textbox, richtextbox but you can easily extend it for other sort of usages.
Using the Code
As you can see in the provided example, there is just one form that is the heart of this On-Screen keyboard. The only thing that must be done in your own application is implementing the type of input control like this:
Keybord VirtualKeyoard = new Keybord();
VirtualKeyoard.PARENT = this;
VirtualKeyoard.SetControl = InputrichText;
int screenHeight = Screen.PrimaryScreen.WorkingArea.Height;
int screenWidth = Screen.PrimaryScreen.WorkingArea.Width;
Point parentPoint = this.Location; int parentHeight = this.Height;
int parentWidth = this.Width;
int resultX; int resultY;
resultY = parentPoint.Y + (this.Height);
resultX = parentPoint.X + 30;
VirtualKeyoard.Location = new Point(resultX, resultY);
Points of Interest
I could not find time to test keyboard in practice, but the initial test was quite OK.