how to check if a key was pressed in unity code example
Example 1: how to check if object has key javascript
myObj.hasOwnProperty('key') // it checks object for particular key and not on prototype
Example 2: unity check when clicked on object
void Update()
{
// Check for mouse input
if (Input.GetMouseButton(0))
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
// Casts the ray and get the first game object hit
Physics.Raycast(ray, out hit);
Debug.Log("This hit at " + hit.point );
}
}
Example 3: python check if key is pressed
import keyboard
if keyboard.is_pressed('b'):
print('b Key was pressed')
Example 4: delphi check if key pressed is enter
procedure TForm1.Memo1KeyPress(Sender: TObject; var Key: Char);
begin
if Key =
begin
// Do something
end;
end;