Keyboard Class

 

About Keyboard Class

 

Keyboard class is mainly used for managing keyboard inputs for specific windows. Note that you must still use Input class for managing inputs for Unity window.

 

Keyboard Class Methods

 

Keyboard.Clear( long WindowHandle ) clears all keyboard states for the given window.

long WindowHandle: window handle.

 

Keyboard.GetKey( long WindowHandle, long Key ) returns true if the specified key is held down or false otherwise.

long WindowHandle: window handle.
long Key: this parameter can be one of the virtual-key codes constants.

 

Keyboard.SetKeyDown( long WindowHandle, long Key ) simulates a key press.

long WindowHandle: window handle.
long Key: this parameter can be one of the virtual-key codes constants.

 

Keyboard.GetKeyDown( long WindowHandle, long Key ) returns true when the user starts pressing down the specified key or false otherwise.

long WindowHandle: window handle.
long Key: this parameter can be one of the virtual-key codes constants.

 

Keyboard.SetKeyUp( long WindowHandle, long Key ) simulates a key release.

long WindowHandle: window handle.
long Key: this parameter can be one of the virtual-key codes constants.

 

Keyboard.GetKeyUp( long WindowHandle, long Key ) returns true when the user releases the specified key or false otherwise.

long WindowHandle: window handle.
long Key: this parameter can be one of the virtual-key codes constants.

 

Code Example

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Giavapps.Windows.API;

public class CodeExample : MonoBehaviour
{

private long WindowHandle = 0;

void Start()
{
Plugin.Initialize();//Initializes Giavapps Windows API
WindowHandle = Window.Create(0, 100, 100, 400, 400, Constant.WS_VISIBLE | Constant.WS_SYSMENU | Constant.WS_MINIMIZEBOX | Constant.WS_MAXIMIZEBOX | Constant.WS_SIZEBOX, Constant.WS_EX_TOPMOST);//Creates a new window
Control.SetText(WindowHandle, "Giavapps Windows API");//Sets a new title for the specified window
}

void Update()
{

//Checks if the specified window has been closed
if(Window.GetClosed(WindowHandle))
{
Control.Destroy(WindowHandle);//Destroys the specified window
}

//Checks if the specified keyboard key has been pressed
if(Keyboard.GetKeyDown(WindowHandle, Constant.VK_SPACE))
{
Debug.Log("SPACE KEY PRESSED!");
}
//Checks if the specified keyboard key has been released
else if(Keyboard.GetKeyUp(WindowHandle, Constant.VK_SPACE))
{
Debug.Log("SPACE KEY RELEASED!");
}

}

void OnApplicationQuit()
{
Plugin.Deinitialize();//Deinitializes Giavapps Windows API
}

}

 

I am Luigi Piscopo, also known as DJ GiDeejay / Producer / Remixer in the music world. I am a Producer with a lot of experience in photo editing, video editing, audio editing, graphic design, web design, programming and promotion.

Comments are closed.