• No results found

Javascript Events / keycodes

N/A
N/A
Protected

Academic year: 2021

Share "Javascript Events / keycodes"

Copied!
24
0
0

Bezig met laden.... (Bekijk nu de volledige tekst)

Hele tekst

(1)

1 mei 2016

Javascript Events / keycodes

En eventueel een subtitel om de nieuwsgierigheid aan te wakkeren

(2)

Javascript move left

2

(3)

1 mei 2016

Javascript move left

3

(4)

Javascript move left setTimeout()

4

(5)

1 mei 2016

Javascript move left setTimeout()

5

(6)

Javascript move Mouse event over

6

(7)

1 mei 2016

Javascript handler

7

Event handler

(8)

Javascript handler

8

Event handler

By convention the event is represented by the variable 'event()'.

In some browsers the event must be explicitly passed to the function, so as a precaution it's often

best to include a conditional to test that the event() variable has been passed, and if it hasn't then to

use an alternative method that works on those other browsers:

(9)

1 mei 2016

Javascript handler

9

Event handler

By convention the event is represented by the variable 'event()'.

In some browsers the event must be explicitly passed to the function, so as a precaution it's often

best to include a conditional to test that the event() variable has been passed, and if it hasn't then to

use an alternative method that works on those other browsers:

(10)

Javascript handler

10

Event attributes

(11)

1 mei 2016

Javascript handler

11

Mouse/keyboard

attributes

(12)

Javascript handler

12

Standard Event

Attributes

(13)

1 mei 2016

Javascript handler

13

Event Handlers as HTML attributes

(14)

Javascript handler

14

Event Handlers as HTML attributes

(15)

1 mei 2016

Javascript handler

15

Writing an event handling script

element.onclick = doSomething;

if (element.captureEvents)

element.captureEvents(Event.CLICK);

function doSomething(e) {

if (!e) var e = window.event // e refers to the event

}

(16)

Javascript handler

16

Writing an event handling script

The target/srcElement properties contain a reference to the HTML element the event originally took place on.

Very useful, but when the event is captured or bubbles up the target/srcElement doesn’t change: it’s still the element the event originally took place on. (See the Event properties page for

target/srcElement, see the this page for the this keyword)

(17)

1 mei 2016

Javascript handler

17

Reading out properties

(18)

Javascript handler

18

Event order

(19)

1 mei 2016

Javascript handler

19

Keycode example

document.addEventListener("keydown", function(event) {

console.log(event.which);

}

(20)

Javascript handler

20

Keycode example

(21)

1 mei 2016

Javascript handler

21

Keycode example

(22)

Javascript handler

22

Keycode

example

(23)

1 mei 2016

Javascript handler

23

Keycode example

windows.onload

(24)

Javascript handler

24

Referenties

GERELATEERDE DOCUMENTEN

They also felt the proposed changes were at odds with the basic premise of conditional hospital orders; they argued that conditional orders are intended mainly for patients who

Judicial interventions (enforcement and sanctions) appear to be most often aimed at citizens and/or businesses and not at implementing bodies or ‘chain partners’.. One exception

Although the answer on the main research question was that implementing the brand equity model only for enhancing decision-making around product deletion is not really affordable

It states that there will be significant limitations on government efforts to create the desired numbers and types of skilled manpower, for interventionism of

We observed a greater anterior positivity (600–900 ms) to preparatory agents as compared to non-preparatory agents and patients (critical panel 1); this positivity indicates

17 Nevertheless, this copying practice showed that the regional press deemed the story relevant to its readers, and in June and July 1763 extensive reports appeared throughout

Interestingly, the degree to which stimuli trigger the retrieval of event files can be controlled (Colzato, Steenbergen, & Hommel, 2018; Keizer, Verment, & Hommel, 2010),

They rejected independence for Bophuthatswana because they maintained that the area of land allocated to the Tswana people in terms of the South African Black Trust and Land