Touch: thuộc tính touchType
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Thuộc tính chỉ đọc touchType của giao diện Touch trả về loại thiết bị tạo ra cử chỉ chạm, chẳng hạn stylus hay ngón tay chạm trực tiếp.
Giá trị
Một chuỗi từ bảng liệt kê TouchType. Các giá trị có thể là:
Ví dụ
>Sử dụng cơ bản
js
someElement.addEventListener(
"touchstart",
(event) => {
for (const touch of event.changedTouches) {
console.log(`Touch type: ${touch.touchType}`);
if (touch.touchType === "stylus") {
// Xử lý input từ stylus, chẳng hạn góc độ cao và phương vị.
console.log(`altitudeAngle: ${touch.altitudeAngle}`);
console.log(`azimuthAngle: ${touch.azimuthAngle}`);
}
}
},
false,
);
Thông số kỹ thuật
| Specification |
|---|
| Touch Events> # dom-touch-touchtype> |