# How to use additionalUserKey and onClick related questions

**URL:** <https://devforum.zoom.us/t/how-to-use-additionaluserkey-and-onclick-related-questions/59543>\
**Category:** Web\
**Created:** [October 29, 2021, 4:48am UTC](https://devforum.zoom.us/t/how-to-use-additionaluserkey-and-onclick-related-questions/59543 "2021-10-29T04:48:02Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Deneb](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/deneb/32/29355_2.png) [@Deneb](https://devforum.zoom.us/u/Deneb)\
**Post date:** [October 29, 2021, 4:48am UTC](https://devforum.zoom.us/t/how-to-use-additionaluserkey-and-onclick-related-questions/59543/1 "2021-10-29T04:48:02Z")

</div>

**Description**  
I want to give an onClick event to the avatar component that is also rendered in the video-canvas, but only the canvas is clicked continuously when I click in the developer tools. My expectation is that the image is still being rendered on the canvas and it is located on the avatar. Is there a good way?  
Second, I want to render the video of the same user on a different canvas. I know I need to use an additionalUserKey, but I need an example or explanation that I can refer to. Can you provide it? Thank you.

 ![image](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/0/4/04f70a037d872888f8753df2163689107ca5bd94.png)

---

<div class="post-metadata">

**Author:** ![tommy](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/tommy/32/72769_2.png) [@tommy](https://devforum.zoom.us/u/tommy)\
**Post date:** [October 29, 2021, 9:44pm UTC](https://devforum.zoom.us/t/how-to-use-additionaluserkey-and-onclick-related-questions/59543/2 "2021-10-29T21:44:06Z")

</div>

Hey @Deneb , happy to help! 🙂

> [@Deneb](#):
>
> I want to give an onClick event to the avatar component that is also rendered in the video-canvas, but only the canvas is clicked continuously when I click in the developer tools. My expectation is that the image is still being rendered on the canvas and it is located on the avatar. Is there a good way?

Can you clarify this one more? I don’t fully understand.

> [@Deneb](#):
>
> Second, I want to render the video of the same user on a different canvas. I know I need to use an additionalUserKey, but I need an example or explanation that I can refer to. Can you provide it?

You can just call renderVideo and pass in the same userId. 🙂

Thanks,  
Tommy

---

<div class="post-metadata">

**Author:** ![Deneb](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/deneb/32/29355_2.png) [@Deneb](https://devforum.zoom.us/u/Deneb)\
**Post date:** [November 1, 2021, 12:18am UTC](https://devforum.zoom.us/t/how-to-use-additionaluserkey-and-onclick-related-questions/59543/3 "2021-11-01T00:18:16Z")

</div>

In this code, i want to give an onClick event to the avatar, but i don’t receive the event because the canvas is constantly on top. I can’t seem to find a good way for the canvas to be placed on top of it while rendering the camera image continuously.  
In the second answer, do you mean that you can put the userId that is renderingVideo into the canvas AdditionalUserKey? have a nice day😊

```auto
 <div
        className={classnames("video-container", {
          "in-sharing": shareScreenState || layoutChange,
        })}
      >
        <canvas
          className="video-canvas"
          id="video-canvas"
          ref={videoRef}
          width="1920"
          height="1080"
        ></canvas>

        <ul className="avatar-list">
          {visibleParticipants.map((user, index) => {
            if (index > videoLayout.length - 1) {
              return null;
            }
            const dimension = videoLayout[index];
            const { width, height, x, y } = dimension;
            const { height: canvasHeight } = canvasDimension;
            return (
              <Avatar
                participant={user}
                key={user.userId}
                testClick={testClick}
                layoutChange={layoutChange}
                isActive={activeVideo === user.userId}
                style={{
                  width: `${width}px`,
                  height: `${height}px`,
                  top: `${canvasHeight - y - height}px`,
                  left: `${x}px`,
                }}
              />
            );
          })}
        </ul>
      </div>
```

---

<div class="post-metadata">

**Author:** ![vic.yang](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/vic.yang/32/24656_2.png) [@vic.yang](https://devforum.zoom.us/u/vic.yang)\
**Post date:** [November 1, 2021, 2:35am UTC](https://devforum.zoom.us/t/how-to-use-additionaluserkey-and-onclick-related-questions/59543/4 "2021-11-01T02:35:24Z")

</div>

Hey @Deneb

The first one, you can consider setting the zIndex of `Avatar` component or setting the canvas as `pointer-events:none` to not react with the click events.

The second one, `AdditionalUserKey` is used in the case of rendering multiple users with the same userId on the same canvas, the `AdditionalUserKey` is an extra key combined with userId to identify the unique drawing cell on the canvas. Following is the example:

```auto
stream.renderVideo(canvas,111222,200,112,0,0,2,'key1');
// render the same user in different location
stream.renderVideo(canvas,111222,200,112,0,400,2,'key2');

// adjust the position of the second drawing
stream.adjustRenderedVideoPosition(canvas,111222,200,112,200,400,2,'key2');

// stop one of the videos, the other videos of same user id still preserved
stream.stopRenderVideo(canvas,111222,'key1');

```

Thanks  
Vic

---

<div class="post-metadata">

**Author:** ![Deneb](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/deneb/32/29355_2.png) [@Deneb](https://devforum.zoom.us/u/Deneb)\
**Post date:** [November 1, 2021, 2:37am UTC](https://devforum.zoom.us/t/how-to-use-additionaluserkey-and-onclick-related-questions/59543/5 "2021-11-01T02:37:29Z")

</div>

God, I tried z-index, but didn’t know pointer-events:none. Thank you so much for the example below. Have a nice day

---

<div class="post-metadata">

**Author:** ![tommy](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/tommy/32/72769_2.png) [@tommy](https://devforum.zoom.us/u/tommy)\
**Post date:** [November 3, 2021, 4:30pm UTC](https://devforum.zoom.us/t/how-to-use-additionaluserkey-and-onclick-related-questions/59543/6 "2021-11-03T16:30:39Z")

</div>

Happy to help! 🙂

-Tommy

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/6/1/614bdd549b610bbaa46ff934617683a02bdaa03c.png) [@system](https://devforum.zoom.us/u/system)\
**Post date:** [December 4, 2021, 2:31am UTC](https://devforum.zoom.us/t/how-to-use-additionaluserkey-and-onclick-related-questions/59543/7 "2021-12-04T02:31:14Z")

</div>

Closed on December 4, 2021, 2:31am UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
