Skip to content

Commit 3b4a14f

Browse files
authored
Merge pull request #224 from abdmmar/abdmmar-branch
Events: change, input, cut, copy, paste
2 parents c02b74d + e0df3df commit 3b4a14f

File tree

1 file changed

+28
-28
lines changed
  • 2-ui/4-forms-controls/3-events-change-input

1 file changed

+28
-28
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
# Events: change, input, cut, copy, paste
22

3-
Let's cover various events that accompany data updates.
3+
Mari kita bahas berbagai *event* yang menyertai pembaruan data.
44

55
## Event: change
66

7-
The `change` event triggers when the element has finished changing.
7+
*Event* `change` terpicu saat elemen selesai diubah.
88

9-
For text inputs that means that the event occurs when it loses focus.
9+
Untuk input teks, itu berarti bahwa *event* terjadi ketika kehilangan fokus.
1010

11-
For instance, while we are typing in the text field below -- there's no event. But when we move the focus somewhere else, for instance, click on a button -- there will be a `change` event:
11+
Misalnya, saat kita mengetik di *field* teks di bawah -- tidak ada *event*. Tetapi ketika kita memindahkan fokus ke tempat lain, misalnya, klik tombol -- akan ada *event* `change`:
1212

1313
```html autorun height=40 run
1414
<input type="text" onchange="alert(this.value)">
1515
<input type="button" value="Button">
1616
```
1717

18-
For other elements: `select`, `input type=checkbox/radio` it triggers right after the selection changes:
18+
Untuk elemen lain: `select`, `input type=checkbox/radio` yang dipicu tepat setelah pilihan berubah:
1919

2020
```html autorun height=40 run
2121
<select onchange="alert(this.value)">
@@ -29,11 +29,11 @@ For other elements: `select`, `input type=checkbox/radio` it triggers right afte
2929

3030
## Event: input
3131

32-
The `input` event triggers every time after a value is modified by the user.
32+
*Event* `input` terpicu setiap kali nilai telah diubah oleh pengguna.
3333

34-
Unlike keyboard events, it triggers on any value change, even those that does not involve keyboard actions: pasting with a mouse or using speech recognition to dictate the text.
34+
Tidak seperti *event* keyboard, *event* `input` memicu perubahan *value* apa pun, bahkan yang tidak melibatkan tindakan keyboard: menempelkan dengan mouse atau menggunakan pengenalan suara untuk mendikte teks.
3535

36-
For instance:
36+
Contohnya:
3737

3838
```html autorun height=40 run
3939
<input type="text" id="input"> oninput: <span id="result"></span>
@@ -44,25 +44,25 @@ For instance:
4444
</script>
4545
```
4646

47-
If we want to handle every modification of an `<input>` then this event is the best choice.
47+
Jika kita ingin menangani setiap modifikasi `<input>` maka *event* ini adalah pilihan terbaik.
4848

49-
On the other hand, `input` event doesn't trigger on keyboard input and other actions that do not involve value change, e.g. pressing arrow keys `key:⇦` `key:⇨` while in the input.
49+
Di sisi lain, *event* `input` tidak dipicu pada input keyboard dan tindakan lain yang tidak melibatkan perubahan nilai, misalnya menekan tombol panah `key:⇦` `key:⇨` saat memasukkan.
5050

51-
```smart header="Can't prevent anything in `oninput`"
52-
The `input` event occurs after the value is modified.
51+
```smart header="Tidak dapat mencegah apa pun di `oninput`"
52+
*Event* `input` terjadi setelah nilai diubah.
5353

54-
So we can't use `event.preventDefault()` there -- it's just too late, there would be no effect.
54+
Jadi kita tidak bisa menggunakan `event.preventDefault()` disana -- terlalu terlambat, tidak akan ada efeknya.
5555
```
5656
5757
## Events: cut, copy, paste
5858
59-
These events occur on cutting/copying/pasting a value.
59+
*Event* ini terjadi saat memotong/menyalin/menempelkan nilai.
6060
61-
They belong to [ClipboardEvent](https://www.w3.org/TR/clipboard-apis/#clipboard-event-interfaces) class and provide access to the data that is copied/pasted.
61+
Mereka termasuk dalam kelas [ClipboardEvent](https://www.w3.org/TR/clipboard-apis/#clipboard-event-interfaces) dan menyediakan akses ke data yang disalin/ditempel.
6262
63-
We also can use `event.preventDefault()` to abort the action, then nothing gets copied/pasted.
63+
Kita juga bisa menggunakan `event.preventDefault()` untuk membatalkan aksi, maka tidak akan ada yang disalin/ditempel.
6464
65-
For instance, the code below prevents all such events and shows what we are trying to cut/copy/paste:
65+
Contohnya, kode di bawah ini mencegah semua *event* tersebut dan menunjukkan apa yang kita coba potong/salin/tempel:
6666
6767
```html autorun height=40 run
6868
<input type="text" id="input">
@@ -74,22 +74,22 @@ For instance, the code below prevents all such events and shows what we are tryi
7474
</script>
7575
```
7676

77-
Please note, that it's possible to copy/paste not just text, but everything. For instance, we can copy a file in the OS file manager, and paste it.
77+
Harap dicatat, bahwa memungkinkan untuk salin/tempel tidak hanya teks, tetapi semuanya. Misalnya, kita dapat menyalin file di manajer file OS, dan menempelkannya.
7878

79-
That's because `clipboardData` implements `DataTransfer` interface, commonly used for drag'n'drop and copy/pasting. It's bit beyound our scope now, but you can find its methods [in the specification](https://html.spec.whatwg.org/multipage/dnd.html#the-datatransfer-interface).
79+
Itu karena `clipboardData` mengimplementasikan *interface* `DataTransfer`, yang biasa digunakan untuk drag'n'drop dan salin/tempel. Ini sedikit di luar jangkauan kita sekarang, tetapi Anda dapat menemukan metodenya [dalam spesifikasi ini](https://html.spec.whatwg.org/multipage/dnd.html#the-datatransfer-interface).
8080

81-
```warn header="ClipboardAPI: user safety restrictions"
82-
The clipboard is a "global" OS-level thing. So most browsers allow read/write access to the clipboard only in the scope of certain user actions for the safety, e.g. in `onclick` event handlers.
81+
```warn header="ClipboardAPI: batasan keamanan pengguna"
82+
*Clipboard* adalah hal "global" tingkat OS. Jadi sebagian besar peramban mengizinkan akses baca/tulis ke *clipboard* hanya dalam lingkup tindakan pengguna tertentu untuk keamanan, misalnya di *event handler* `onclick`.
8383
84-
Also it's forbidden to generate "custom" clipboard events with `dispatchEvent` in all browsers except Firefox.
84+
Juga dilarang untuk membuat *event* *clipboard* "custom" dengan `dispatchEvent` di semua peramban kecuali Firefox.
8585
```
8686

87-
## Summary
87+
## Ringkasan
8888

89-
Data change events:
89+
*Event* perubahan data:
9090

91-
| Event | Description | Specials |
91+
| *Event* | Deskripsi | Specials |
9292
|---------|----------|-------------|
93-
| `change`| A value was changed. | For text inputs triggers on focus loss. |
94-
| `input` | For text inputs on every change. | Triggers immediately unlike `change`. |
95-
| `cut/copy/paste` | Cut/copy/paste actions. | The action can be prevented. The `event.clipboardData` property gives read/write access to the clipboard. |
93+
| `change`| Sebuah *value* diubah. | Untuk pemicu input teks pada saat kehilangan fokus. |
94+
| `input` | Untuk input teks pada setiap perubahan. | Pemicu langsung tidak seperti `change`. |
95+
| `cut/copy/paste` | Tindakan potong/salin/tempel. | Tindakan tersebut dapat dicegah. Properti `event.clipboardData` memberikan akses baca/tulis ke *clipboard*. |

0 commit comments

Comments
 (0)