Trending December 2023 # Examples And Nested Begin & End Keyword Usage # Suggested January 2024 # Top 12 Popular

You are reading the article Examples And Nested Begin & End Keyword Usage updated in December 2023 on the website We hope that the information we have shared is helpful to you. If you find the content interesting and meaningful, please share it with your friends and continue to follow and support us for the latest updates. Suggested January 2024 Examples And Nested Begin & End Keyword Usage

Introduction to Begin SQL

Begin SQL is the keyword that is used to mark up and specify the beginning of the transaction or stored procedure or functions or simply the collection of multiple statements inside the logical block whose body starts from the specification of the BEGIN keyword and stops with the use of END keyword. We can write the sequence of the statement that we wish to execute inside the BEGIN and END keywords in SQL. Multiple BEGIN END statements can be written inside the same method or stored procedure, etc. We can even write nested BEGIN END statements in SQL where the logical block of statements defined between BEGIN and END keywords can be executed on a conditional basis or inside the loops and other functions according to the use case and requirement.

Start Your Free Data Science Course

In this article, we will learn about the syntax of using the BEGIN keyword in SQL and the END keyword that helps create a logical block of SQL statements with the help of syntax and few examples.


The following is the syntax of using the BEGIN keyword in SQL, which is accompanied with END for termination of the block of statements –


The use of BEGIN is mostly done in Transact-SQL, where multiple statements are executed completely in a transactional manner to maintain the consistency of the database operations and ACID properties of the database. We can mention the statements that we want to execute in a transactional manner inside the BEGIN and END keywords, as shown in the above syntax. The statements inside the BEGIN and END are also known as the batch that is executed together. We can mention the set of statements of SQL inside the BEGIN and END keywords.

Let us consider a few of the examples that will make the implementation of BEGIN in SQL clear to you.

Examples of Begin SQL

We will consider one existing table named students that are present inside the database named educba on my SQL server. The structure and contents of the table students can be seen from the output of the following query statement –

SELECT * FROM students;

The output of the execution of the above query statement is as follows –

The students’ table contains 14 records in it. Now, we want to execute three statements in the transact SQL that includes the addition of two records named Karna and Yudhishthira to the students’ table and, upon addition, retrieval of the records of the students’ table. We will place our SQL query statements of INSERT and SELECT queries inside the BEGIN and END keyword as shown in the below code –

BEGIN INSERT INTO `students` (`student_id`, `class_id`, `name`, `roll`, `technology`, `percentage`) VALUES('15','3','Karna','Manager','Maven','96%'); INSERT INTO `students` (`student_id`, `class_id`, `name`, `roll`, `technology`, `percentage`) VALUES('16','2','Yudhistir','Administrator','MySQL','92%'); SELECT * FROM students; END

The output of the execution of the above query statements and block is as follows –

We can observe that the two additional records have been inserted into the students’ table, and now, the students’ table contains 16 records in total that are retrieved from the third SELECT query that we mentioned in our logical block between BEGIN and END keywords.

Let us now consider one more example in which we want to get the records of the student’s names and id that have a percentage greater than 92, and if no records are retrieved, then it should give the output as ‘No students found that have achieved percentage greater than 92’. For this, we will first select the records from the student’s table that will have a percentage greater than 92 using the select query, and then if the row count of the retrieved query is zero, then we will select the string literal value that will contain the sentence as required when no such record is found.

We will use the IF statement to check the row count condition and will place all these statements inside the BEGIN and END to make them a single logical block that will consist of our statements as shown below –

BEGIN SELECT student_id, NAME FROM educba.students WHERE IF @@ROWCOUNT = 0 SELECT 'No students found that have achieved percentage greater than 92'; END

The output of the execution of the above query statements and block is as follows –

Nested BEGIN and END keyword usage

We can even make the use of nested BEGIN END blocks inside each other and create different logical blocks of statements to be executed. The BEGIN and END togetherly work as { and } in C, JAVA, or any other language. We can execute these logical blocks based on some conditions and also repetitively inside various looping statements of SQL.

Let us consider one simple example of nested BEGIN END blocks in SQL that will retrieve the name of the students that are ordered in the descending manner of their percentages and then get the value of the first record from the query that retrieves the names of students and stores the name of the student with the highest percentage inside the variable named @name. Further, we want to check if the row count of the result set of the query statement is not equal to zero, then print the value of the name in the string ‘The highest scoring student is the name of student else execute another block of BEGIN END that will get the string value ‘No student found’. We will use the following code for that –

BEGIN DECLARE @name VARCHAR(100); SELECT @name = NAME FROM educba.students ORDER BY percentage DESC; BEGIN SELECT 'The most highest scoring student is ' + @name; END ELSE BEGIN SELECT 'No student found'; END; END

The output of the execution of the above query statements and block is followed, retrieving the name of student Karna that has the highest percentage that is 96% –


We can make the use of the BEGIN keyword in SQL to mark the starting point of the logical block of statements of transact SQL that we need to specify and use the END keyword to specify the closing point of a logical block in SQL.

Recommended Articles

We hope that this EDUCBA information on “Begin SQL” was beneficial to you. You can view EDUCBA’s recommended articles for more information.

You're reading Examples And Nested Begin & End Keyword Usage

Definition And Syntax With Examples

Definition of MySQL AES_Encrypt

The MySQL AES_Encrypt function implements the AES algorithm to encode a provided string as arguments. The AES algorithm, which stands for Advanced Encryption Standard, encrypts the data using a key length of 128 bits, extendable up to 256 bits. MySQL AES_Encrypt() encodes a specific string and produces a binary series. If the argument provided to the function is NULL, the output will also be NULL.

Start Your Free Data Science Course

Hadoop, Data Science, Statistics & others

We, a user, provide too small a key length. It may be null-padded, i.e., due to the memset, but if it’s too big, then it may xor the additional bytes using the first key_size bytes; suppose when the critical size will be 4bytes along with the key as 12345678, then it will be xor to 5678 using the outcome as the key with 1234. Therefore, for the best security, we must implement a random key length of the size configured AES to be used. Hence, for providing AES-128, we need a 128-bit as a random key or 32 hex characters.

Syntax of MySQL AES_Encrypt AES_ENCRYPT (Encryp_String, Key_String);

The function named Encryp_String describes the arguments mentioned above, which are Encryp_String and Key_String.

Encryp_String:  This string will be encrypted.

Key_String: This is the key string to encrypt the first argument String.

These input arguments can be of any length. If any of these arguments, such as the key value or the string to be encrypted, are NULL, the function will return NULL. AES is an algorithm that operates at the block level, where padding encodes strings of irregular lengths. The resulting length of the string can be calculated using the following formula:

16 * (trunc(str_len/16) + 1);              

AES is a two-way encryption and decryption mechanism that provides security for sensitive data records while allowing the original data to be retrieved. The AES algorithm utilizes an encryption key as a seed to achieve this. AES implements a compound mathematical algorithm comprising two concepts: confusion and diffusion. Here, the confusion process helps to hide the relationship between the original data and the encrypted data result. In contrast, the Diffusion process functions to shift, alter or adjust the data compositely.

When executed, the function AES_ENCRYPT() in MySQL will return the value, which is a binary string, after converting the original plaintext. The MySQL AES_ENCRYPT() function supports MySQL versions 5.7, 5.6, 5.5, 5.1, 5.0, and 4.1.

How does AES_ENCRYPT Function Work in MySQL?

AES_ENCRYPT() function in MySQL applies encryption of data records by using the official AES algorithm, formerly recognized as ‘Rijndael’, where the AES standard allows several key lengths. The default key length is 128 bits, but 196 and 256 bits can also be implemented as described. The key length in AES is a trade-off between safety and performance.

Let us view the code example to show the working of the AES_Encrypt() function as below:

SELECT AES_Encrypt('mysqlcoding','mysqlkeystring');

The above MySQL query statement encodes the string specified like ‘mysqlcoding’ with the key mysqlkeystring. The output for this will be the following after execution:

AES_Encrypt() allows the regulator of the block encryption mode and will receive init_vector as an optional initialization vector argument where:

This system variable block_encryption_mode governs the mode for the server’s block-based encryption algorithms whose value is aes-128-ecb by default, indicating encryption using a key length of 128 bits and mode ECB.

The optional argument init_vector delivers an initialization vector for this block encryption mode, which needs it.

Modes that require the init_vector argument should have a length of 16 or more bytes, with any bytes beyond 16 being ignored. But an error will take place if init_vector is missing. So we can write as follows:

SELECT AES_ENCRYPT (Encryp_String, Key_String, @init_vector);

But the modes that do not need the optional argument init_vector will be disregarded, and an associated warning is produced if it is stated.

To use an initialization vector (IV), a random string of bytes can be generated by invoking RANDOM_BYTES(16). When the encryption mode requires an IV, you should consistently use the generated vector for the encryption and decryption of any string.

Certainly! Below is a table list that explains various allowed block encryption modes along with the associated initialization vector (IV) argument required:

Block Encryption Mode  Initialization Vector Needed



CFB1 Yes

CFB8 Yes

CFB128 Yes


Examples of MySQL AES_Encrypt

Let us illustrate some examples to show the MySQL AES_Encrypt() function works as follows:

1. Executing AES_Encrypt() function on a string by SELECT statement:


The MySQL AES_Encrypt() uses the SELECT statement to find the outcome and encrypt the string in the MySQL server.


2. Executing AES_Encrypt() function on a bigger string by SELECT statement:

SELECT AES_ENCRYPT('MySQLdatabasefunction','key');




4. Executing AES_Encrypt() function implementing a sample table in the database:

INSERT INTO demo VALUE (AES_ENCRYPT('mystring','key'));

If explained in the above query, the function encrypts the particular string mystring with a key and enters the encrypted string as output into the table ‘demo’.

5. Executing AES_ENCRYPT() function with key value:

SELECT AES_ENCRYPT('All is Well','Google');


The AES_ENCRYPT() function accepts the key value “Google” and the string to be encrypted, “All is Well,” as arguments.


The MySQL AES_ENCRYPT() function is considered insecure because it defaults to using ECB mode unless configured otherwise.

Depending on what the server’s block_encryption_mode a user configures, we can use the key length from the list of supported ones, such as 128, 256, and 192, where the AES standard algorithm also permits these key lengths.

Recommended Articles

We hope that this EDUCBA information on “MySQL AES_Encrypt” was beneficial to you. You can view EDUCBA’s recommended articles for more information.

It Adoption Of Vista To Begin In 2008

Microsoft released the near final version of the first service pack for Windows Vista this week, and a new report predicts that the system’s corporate heyday is just around the corner.

The report by analysis firm Forrester Research predicts that while deployments of Vista in enterprises to date have been slow, that dam is about to break.

“The era of Windows Vista within enterprises has officially started, with a whimper. But think of it as the snowflakes before the storm,” analyst Benjamin Gray wrote in the report, which is titled “How Windows Vista Will Shake Up The State Of The Enterprise Operating System.”

The upshot: deployments among many enterprises will be well underway by late-2008, the firm’s research predicts, and will likely snowball from there.

Meanwhile, Microsoft officials confirmed that the company began sending out this week copies of the first Vista Service Pack 1 (SP1) Release Candidate, or “RC.” This is the final step in testing before a product or a service pack is released for commercial use.

That puts Vista SP1 on schedule for shipment during the first quarter of 2008, the spokesperson added.

Meanwhile, Forrester’s study found that, among North American and Global 2000 enterprises, so far just 3 percent of PCs are running Windows Vista. In European countries, movement to the new operating system is negligible so far.

The report found that many IT shops are still waiting for Vista SP1, but that doesn’t mean they’re on the fence about whether to go to Vista in the longer term.

Indeed, almost half of the respondents said their companies have “concrete plans” to deploy Vista. Some seven percent plan to begin that process by the end of 2007, while 32 percent plan to have the move underway by the end of 2008. Another 17 percent plans to roll out Vista in 2009 or beyond.

“Forrester predicts that next year Windows Vista will be deployed across at least one-quarter of PCs in North American and European enterprises. By then, desktop managers will have started moving away from the Windows XP platform, although it will still run the majority of PCs within corporate environments,” the report states.

It’s all part of a fairly predictable pattern, according to one long-time Windows watcher, who called Forrester’s predictions “a safe bet.”

When a new client version of Windows comes out, although Microsoft talks it up loudly, customers – especially IT shops – inevitably say they’re holding off making any decisions. Often, they’re waiting for the first service pack for the new system to arrive – which typically takes anywhere from six months to a year after the system first ships – to prove that the OS is finally fully baked.

Additionally, besides Vista SP1, large customers may be waiting for the delivery of key new server products early next year, he added. For instance, Windows Server 2008, along with SQL Server 2008 and Visual Studio 2008, is scheduled to launch on February 27, 2008, and to be available to customers by the end of March.

“[Large customers] may be thinking ‘We’re going to deploy the server first, because there are fewer of them, and then deploy Vista,” Cherry said.

The Forrester report also identifies another roadblock Microsoft faces with Vista. Forrester researchers found that among the 565 PC decision makers at large companies who participated in the study, 84 percent of enterprises in both the U.S. and the world at large are currently running XP as a standard. As it has turned out, XP has proven to be a very stable environment.

And, as Microsoft executives have stated for years, when the company comes out with a new version of Windows, its biggest competitor is always the previous version of Windows. But that is not to say that Vista deployments are permanently blocked.

Indeed, while XP is firmly ensconced in many organizations, eventually Vista will be phased in to replace it, according to both Forrester and Cherry. After all, while it’s stable, XP first shipped in 2001, Forrester’s report notes.

So although half of the Forrester survey respondents had no plans regarding Vista at the point that the survey was conducted – April to June 2007 – that number is expected to shrink after Vista SP1 is released.

As a matter of fact, Microsoft just turned in its best fiscal first quarter in the past eight years, due partly to increasing sales of Vista.

In fact, while the changeover to Vista may not come as quickly as Microsoft and its partners would like, it still constitutes a juggernaut that will inevitably displace XP as the corporate desktop standard.

“It’s not as if everyone’s going to stay on XP,” said Cherry. “There’s going to be this momentum switch.”

This article was first published on chúng tôi

Merging Ai And Hpc To Begin A New Era Of Tech At Space Discoveries

Huerta’s innovation will help observe the cosmos more clearly at space

Black holes are always a hot topic among astronauts. One of the reasons behind it is that black holes are unpredictable and far away, making researchers wonder what they can do. However, in recent years, 

Huerto’s initiative to merge AI and high-performance computing (HPC) Discovering black holes using disruptive technology 

Recently, astronomers announced that they had detected a massive 

Having a binocular view at black hole spin

Huerta and two of his students created a more sophisticated neural network that can detect the motion of two colliding black hole’s spin. The AI model accurately measured the faint signals of a small black hole merging with a larger one.

Black holes are always a hot topic among astronauts. One of the reasons behind it is that black holes are unpredictable and far away, making researchers wonder what they can do. However, in recent years, Artificial Intelligence (AI) features have helped scientists figure out answers using technology for their confusion. Since the discovery of phosphine gas in the clouds of Venus , the planet that is incapable of housing living beings because of its high temperature, the intensity of expectation on space has widened drastically. Scientists are looking at new possibilities in the expanded no ending topic. The ancient stories of aliens coming to earth in weird space vehicles are still attractive to everyone. Henceforth, AI is aiding researchers to zoom in more at the vast black space. Their focus is heavily on black holes that never seem to conclude. Black holes are points in space that are so dense to create deep gravity sinks. They even resist light to pass through its surface. Anything that goes too near the black hole, whether it is a star, planet, or spacecraft, will be stretched and compressed like putty in a theoretical process aptly known as spaghettification. If humans go into black holes, they are predicted to be shattered into pieces. Albert Einstein first predicted the existence of black holes in 1916 with his theory of relativity. Almost after five decades, black holes got its name. Since then, scientists and researchers are looking at ways to deepen their research on black holes. The new trending way to learn about black holes is by suing the technological features of artificial intelligence. It is not just black holes unraveled by AI; other space-related topics are also interconnecting with AI for better discovery. Eliu Huerta is a scientist from the National Centre for Supercomputing Applications and Department of Astronomy, University of Illinois. He has merged AI and high-performance computing (HPC) to observe the cosmos more clearly at space. For several years, astrophysics researchers used data to detect signals produced by collisions of black holes ad neutron stars. Huerta’s research, if succeeded, will be a breakthrough to the space discoveries. It is expected to answer a thousand unanswered and prolonged questions. However, the debates on space-time fabric ended in 2023 when researchers observed the gravitational waves for the first time. They used pattern-matching techniques on data from the Laser Interferometer Gravitational-Wave Observatory (LIGO), home to some of the most sensitive instruments in science.Recently, astronomers announced that they had detected a massive collision of two black holes ever discovered. The clash is expected to have happened seven billion years ago, leaving only the late signs to humans. The cataclysmic event offered researchers a front-row seat to the birth of one of the Universe’s most elusive objects. A team of researchers in 2023 used an AI bot named ‘ClaRAN’ that scans images taken by radio telescopes, which could spot the galaxies that emit powerful radio jets from supermassive black holes at their centers. It was then discovered by data specialist Dr. Cheu Wu and astrologer Dr. Ivy Wong from the University of Western Australia node of the International Centre for Radio Astronomy Research (ICRAR). Ultimately, the new technology to discover space-related information in the trending 2023 is supercomputers that process the data that instruments gather in a single day. In 2023, Huerta’s team showed how a deep neural network running on an NVIDIA GPU could find gravitational waves with the same accuracy in a fraction of the time. The AI model Huerta used was based on data from tens of thousands of waveforms. He trained it on a single NVIDIA GPU in less than three hours.Huerta and two of his students created a more sophisticated neural network that can detect the motion of two colliding black hole’s spin. The AI model accurately measured the faint signals of a small black hole merging with a larger one. The trio used an IBM POWER9-based system with 64 NVIDIA V100 Tensor Core GPUs that took 12 hours to train the resulting neural network with a requirement of 1.5 million waveforms. To further the process, the Huerto team got access to 1,536 V100 GPUs on 256 nodes of the IBM AC922 Summit supercomputer at Oak Ridge National Laboratory. By making a connection between Summit’s GPUs and its IBM POWER9CPUs, they trained the model in 1.2 hours. This is quite an achievement in the evolving outer space stories. The result was published in ‘ A paper in Physics Letters B .’ It showed the combination of AI and HPC, which solved challenges in astrophysics. The innovation is marking a milestone in Artificial Intelligence’s extensive features and its functions on space-related topics. Both space and AI are something that induces curiosity. It will be interesting to see the emerging discoveries from space and AI gadgets or technologies that feature the discoveries.

Deregulation: Meaning, Causes, Effects, Examples, And Benefits

What is Deregulation?

Deregulation is removing, reducing, or replacing government rules to increase competition within the sector or industry. For instance, during covid, laws regarding doctors obtaining licenses before using telehealth systems were deregulated, as these laws were restricting Medicare beneficiaries’ access to remote treatment.

Deregulation aims to open up business operations, improve decision-making, and eliminate corporate constraints. It enables private banks to regulate their financial functions regarding their capital investments and allocations. It provides them the edge to compete globally.

Key Highlights

Steep competition fosters innovation, and consumers enjoy lower prices when there is perfect competition.

It encourages economic development by allowing businesses to operate more freely.

Also, smaller companies won’t be able to compete with bigger firms due to legacy growth over the years.

How Does Deregulation Work?

Start Your Free Investment Banking Course

Download Corporate Valuation, Investment Banking, Accounting, CFA Calculator & others

Reducing rules, regulations, and workings allows for greater investment, money, market, and exchange opportunities. Before the great depression, there was proper regulation of financial institutions. However, the learned lesson post the year 1929 was autonomy and independence. Banks had more freedom in deciding their financial standing, which helped them balance valuations and reduce the operating costs that the government controls in power.

Discourses concerning rules evolve; the fundamental reason is that some laws become ineffective and restrictive over time. An illustration would be how former US President Donald Trump relaxed various laws that acted as barriers to accessing health care, including telehealth, as part of his policy reaction to COVID-19. Hence, it is a must for positive economic growth.

Examples #1: Banking Industry

Banks in the United States were not allowed to undertake their client’s money to buy securities exchanges due to higher volatility. However, after the deregulation of the Glass-Steagall Act’s repeal in 1999, banks started investing the client’s money leading to further crashes in the market and loss of client’s money.

#2: Aviation Industry Importance

It provides autonomy that eases the mode of doing business and provides greater flexibility in the decision-making process.

The banks can enjoy lower prices as a capital investment due to the match-up of supply and demand variables that affect the financial world.

It helps create physical capital and financial resources.

Causes Market-growth Acceleration

It helps in accelerating market growth and the opportunities attached to it.

Business profitability improves economic growth.

Innovation Encouragement

Entrepreneurs can foster innovation and creativity in the financial landscape by experimenting with numbers.

Unnecessary regulation inhibits innovation.

Ensure Business Freedom

Businesses can have the freedom to innovate and experiment with new modus operandi.

The company gets the flexibility to follow less stringent policy measures.


New business opportunities exist in the marketplace due to less or no regulation that enhances investment opportunities.

It also increases competition among the firms, leading to perfect competition and lowering prices.

Due to the autonomy provided, businesses develop new products, cut costs, and focus on operational optimization.


It caters to economic growth by fostering autonomy, innovation, and higher expansion of production services.

Allows the new private players to try their hands at creating a healthy business environment.

It gives more flexibility to the government to keep a check on the market by introducing technology without getting into IT Acts.

Final Thoughts

Market failures are the key reasons to remove deregulation in the economy. An economy cannot function effectively without regulation as it keeps autonomy in check and restricts the stakeholders from making informed decisions. It comes with easing stringent policy restrictions concerning the internal economy, as it will boost the country’s reputation at a global level.

Frequently Asked Questions (FAQs) Q1. What is deregulation?

Answer: Deregulation is a procedure for reducing government control in a segmented market that typically helps gain a competitive edge. The fiasco between the components of regulation and the government non-interventions has created chaos in the market condition.

Q2. What is an example of deregulation?

Answer: There have been many instances of deregulation in the world. Some examples are the Airline in the US, Mail Delivery in the UK, and the Energy sector in the UK.

Q3. What are the reasons for deregulation? Q4. Who benefits from deregulation?

Answer: Deregulation benefits Businesses, corporations, and governments due to policy ease and higher autonomy.

Q5. What is another term for deregulation?

Answer: Privatization, re-regulations, and centralization are some other deregulation terms.

Q6. How deregulation helps the banks?

Answer: Deregulation provides a free hand to increase investment, capital, market, and exchange opportunities by slashing laws, regulations, and workings. It gives financial institutions and global banks autonomy to make informed decisions on investment opportunities.

Recommended Articles

We hope this practical guide from EDUCBA on deregulation was helpful. For further knowledge, we recommend these articles,

Keycodes Table And Examples Of Jquery Keycode

Introduction to jQuery keycode

jQuery key code is used to the mapping of keycodes to their numeric values. Key codes are the keyboard keys to which have digital values mapped to the keys based on the key code description. jQuery keycode is a part of Themes in jQuery UI API category, there are many more API’s like disableSelection(), enableSelection(), .uniqueId(), .zIndex(), .focus() provided by chúng tôi function in jQuery UI. This jQuery UI was built upon jQuery JavaScript’s library for User Interface, Effects, Themes, Widgets, and User Interaction. The recommended version of jQuery UI is v1.10. Let’s have a look at Syntax and how jQuery keycodes work.

Start Your Free Software Development Course

Web development, programming languages, Software testing & others



Before getting into examples of jQuery keycode, we need to know KeyCodes Table.

KeyCode Description/ Numeric value

Backspace 8

Tab 9

Enter 13

Shift 16


ALT 18

Pause/ Break 19

Caps Lock 20

ESC 27

Page Up 33

Page Down 34

End 35

Home 36

Arrow Left 37

Arrow Up 38

Arrow Right 39

Arrow Down 40

Insert 45

Delete 46

0 48

1 49

2 50

3 51

4 52

5 53

6 54

7 55

8 56

9 57

;: 59

=+ 61

a 65

b 66

c 67

d 68

e 69

f 70

g 71

h 72

i 73

j 74

k 75

l 76

m 77

n 78

o 79

p 80

q 81

r 82

s 83

t 84

u 85

v 86

w 87

x 88

y 89

z 90

Windows 91


0(Num Lock) 96

1(Num Lock) 97

2(Num Lock) 98

3(Num Lock) 99

4(Num Lock) 100

5(Num Lock) 101

6(Num Lock) 102

7(Num Lock) 103

8(Num Lock) 104

9(Num Lock) 105

*(Num Lock) 106

+(Num Lock) 107

-(Num Lock) 109

.(Num Lock) 110

/(Num Lock) 111

F1 112

F2 113

F3 114

F4 115

F5 116

F6 117

F7 118

F8 119

F9 120

F10 121

F11 122

F12 123

Num Lock 144

Scroll Lock 145

My Computer 182

My Calculator 183

,< 188


/? 191

`~ 192

[{ 219


]} 221

‘” 222

Examples of jQuery keycode

Here are the following examples mention below

Example #1

jQuery keycode with onkeypress()

function sampleKeyCode(event) { var keycode = (event.keyCode ? event.keyCode : event.which); document.getElementById(“demoKey”).innerHTML = “The Numeric value is: ” + keycode; }


On entering any key value, for, e.g. Entering ‘A’, the numerical value for ‘A’ is 65, as shown below.

On entering ‘b’, the numerical value for ‘b’ is 98. (onKeyPress) as shown below. If onKeyDown, the value of ‘b’ will be 66.

On entering the ‘Enter’ key, the value of the ‘Enter’ key is 13, as shown below

Example #2

jQuery keyCode with onKeydown().

function sampleKeyCode(event) { var keycode = (event.keyCode ? event.keyCode : event.which); document.getElementById(“demoKey”).innerHTML = “The Numeric value is: ” + keycode; }

// The only difference between Example 1 and Example 2 here are the key events. In the previous example, we used onKeypress(), now we have used onKeydown().

On entering value ‘b’, the numeric keycode is 66, as shown below

Example #3

jQuery keyCode: key-value based on numeric value

function sampleKeyCode(event) { var keycode = (event.keyCode ? event.keyCode : event.which); if(keycode == ’13’){ alert(‘You pressed a “enter” key in textbox’); } else if(keycode == ’45’){ alert(‘You pressed a “Insert” key in textbox’); } else if(keycode == ‘9’){ alert(‘You pressed a “Tab” key in textbox’); } else if(keycode == ’48’){ alert(‘You pressed a “0” key in textbox’); } else if(keycode == ’90’){ alert(‘You pressed a “z” key in textbox’); } else if(keycode == ‘112’){ alert(‘You pressed a “F1” key in textbox’); } else if(keycode == ‘219’){ alert(‘You pressed a “[ or {” key in textbox’); } else{ alert(‘You pressed some other key in textbox’); } }


On pressing the ‘Insert’ key,

On pressing ‘Enter’,

On pressing any other key,

As the keycode returns the Unicode character code of the key that is triggered here on the keypress event, we have two types of code types:

Character codes and  Key Codes: Key codes represent the actual key of the keyboard, whereas Character code represents ASCII character.


With this, we conclude the topic ‘jQuery keycode’, we have seen what jQuery keycode and its syntax is and how it is used to get the keyCode of a particular keyboard value. Listed out the keyCodes for maximum keys of the keyboard. So that you can have this table or refer and try to give some hands-on this topic. Explained a few examples also can be useful to find out key codes or the Unicode character codes. We have 3 events here, onKeydown(), onKeyup(), or onKeypress(), examples above shown are using onKeypress() and onKeydown() events.

Recommended Articles

This is a guide to jQuery keycode. Here we discuss the Examples of jQuery keycode along with the codes and outputs and how it is used to get the keyCode of a particular keyboard value. You may also have a look at the following articles to learn more –

Update the detailed information about Examples And Nested Begin & End Keyword Usage on the website. We hope the article's content will meet your needs, and we will regularly update the information to provide you with the fastest and most accurate information. Have a great day!