# At first, there was no response when the mouse clicked into canvas and then operated with the keyboard

**URL:** <https://forum.babylonjs.com/t/at-first-there-was-no-response-when-the-mouse-clicked-into-canvas-and-then-operated-with-the-keyboard/27806>\
**Category:** Questions\
**Created:** [February 19, 2022, 1:11pm UTC](https://forum.babylonjs.com/t/at-first-there-was-no-response-when-the-mouse-clicked-into-canvas-and-then-operated-with-the-keyboard/27806 "2022-02-19T13:11:59Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![ChenJiong-0819](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/chenjiong-0819/32/19355_2.png) [@ChenJiong-0819](https://forum.babylonjs.com/u/ChenJiong-0819)\
**Post date:** [February 19, 2022, 1:11pm UTC](https://forum.babylonjs.com/t/at-first-there-was-no-response-when-the-mouse-clicked-into-canvas-and-then-operated-with-the-keyboard/27806/1 "2022-02-19T13:11:59Z")

</div>

When I first entered the game, the keyboard keys did not respond. I need to move the cursor out of the canvas, click (red arrow), and then click back into the canvas (green arrow). The keyboard keys can be triggered.  
 ![111111](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/b/2/b29bdaacf5a5341dfddd834be5a427d5e7f862df.png)  
At first, when the mouse clicks into the canvas and then operates with the keyboard, there is no response. You need to click elsewhere and then click back into the canvas to trigger the keyboard event

---

<div class="post-metadata">

**Author:** ![roland](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/roland/32/38940_2.png) [@roland](https://forum.babylonjs.com/u/roland)\
**Post date:** [February 19, 2022, 1:30pm UTC](https://forum.babylonjs.com/t/at-first-there-was-no-response-when-the-mouse-clicked-into-canvas-and-then-operated-with-the-keyboard/27806/2 "2022-02-19T13:30:59Z")

</div>

There can be multiple reasons for this. Do you capture the keyboard events on the bjs rendering canvas? Can you provide a full example?

---

<div class="post-metadata">

**Author:** ![ChenJiong-0819](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/chenjiong-0819/32/19355_2.png) [@ChenJiong-0819](https://forum.babylonjs.com/u/ChenJiong-0819)\
**Post date:** [February 19, 2022, 1:44pm UTC](https://forum.babylonjs.com/t/at-first-there-was-no-response-when-the-mouse-clicked-into-canvas-and-then-operated-with-the-keyboard/27806/3 "2022-02-19T13:44:11Z")

</div>

You can try this link below, but to download, please

> **[GitHub - ChenJiong-0819/Lamp\_Hanabi-2022: 这是一个用Babylon.js制作的3D游戏](https://github.com/ChenJiong-0819/Lamp_Hanabi-2022/tree/master)**
>
> master

---

<div class="post-metadata">

**Author:** ![roland](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/roland/32/38940_2.png) [@roland](https://forum.babylonjs.com/u/roland)\
**Post date:** [February 19, 2022, 2:47pm UTC](https://forum.babylonjs.com/t/at-first-there-was-no-response-when-the-mouse-clicked-into-canvas-and-then-operated-with-the-keyboard/27806/4 "2022-02-19T14:47:49Z")

</div>

Ok, got the repo. I will get back to you later. I need to finish something.

---

<div class="post-metadata">

**Author:** ![ChenJiong-0819](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/chenjiong-0819/32/19355_2.png) [@ChenJiong-0819](https://forum.babylonjs.com/u/ChenJiong-0819)\
**Post date:** [February 19, 2022, 3:32pm UTC](https://forum.babylonjs.com/t/at-first-there-was-no-response-when-the-mouse-clicked-into-canvas-and-then-operated-with-the-keyboard/27806/5 "2022-02-19T15:32:35Z")

</div>

OK, OK, thank you. Please reply to me when you are free. Please.

---

<div class="post-metadata">

**Author:** ![roland](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/roland/32/38940_2.png) [@roland](https://forum.babylonjs.com/u/roland)\
**Post date:** [February 19, 2022, 3:43pm UTC](https://forum.babylonjs.com/t/at-first-there-was-no-response-when-the-mouse-clicked-into-canvas-and-then-operated-with-the-keyboard/27806/6 "2022-02-19T15:43:43Z")

</div>

I made these changes:

1. upgraded BabylonJS to version 5
2. changed `index.html` - added the canvas directly to the html and made it to cover the whole screen
3. removed the `canvas` creation from app.ts

You can download it from here:  
[https://misc.babylonjs.xyz/Lamp\_Hanabi-2022.zip](https://misc.babylonjs.xyz/Lamp_Hanabi-2022.zip)

Copy over your files. Run `npm i`. Enjoy!

r 🖖

---

<div class="post-metadata">

**Author:** ![ChenJiong-0819](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/chenjiong-0819/32/19355_2.png) [@ChenJiong-0819](https://forum.babylonjs.com/u/ChenJiong-0819)\
**Post date:** [February 19, 2022, 4:25pm UTC](https://forum.babylonjs.com/t/at-first-there-was-no-response-when-the-mouse-clicked-into-canvas-and-then-operated-with-the-keyboard/27806/7 "2022-02-19T16:25:35Z")

</div>

thank you very much!!  
I didn’t upgrade babylongjs, I just changed the index HTML - add the canvas directly to HTML and make it cover the whole screen. Canvas starts from app The creation is deleted in TS, which solves the problem that keyboard events are not triggered at the beginning.  
Can you tell me why you can create HTML directly without this problem? I wonder why.

👏 👏 👏 😃 😃

---

<div class="post-metadata">

**Author:** ![roland](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/roland/32/38940_2.png) [@roland](https://forum.babylonjs.com/u/roland)\
**Post date:** [February 19, 2022, 4:29pm UTC](https://forum.babylonjs.com/t/at-first-there-was-no-response-when-the-mouse-clicked-into-canvas-and-then-operated-with-the-keyboard/27806/8 "2022-02-19T16:29:11Z")

</div>

I think the event binding occured earlier than the canvas was created dynamically or something like that. I didn’t dig deeper, you know, I’ve got a lot to do… ☹

> [@ChenJiong-0819](#):
>
> thank you very much!!

You are welcome buddy!

---

<div class="post-metadata">

**Author:** ![ChenJiong-0819](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/chenjiong-0819/32/19355_2.png) [@ChenJiong-0819](https://forum.babylonjs.com/u/ChenJiong-0819)\
**Post date:** [February 19, 2022, 4:44pm UTC](https://forum.babylonjs.com/t/at-first-there-was-no-response-when-the-mouse-clicked-into-canvas-and-then-operated-with-the-keyboard/27806/9 "2022-02-19T16:44:12Z")

</div>

OK, OK, thank you very much!!!
